3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '<?xml version="1.0" encoding="UTF-8"?><ns3:entDocumentResponse xmlns="http://domain.com/dictionary/technical/" xmlns:ns2="http://domain.com/services/entityService/document/GetContentUrl_1_0" xmlns:ns3="http://domain.com/services/entityService/document/1.0"> <activities/> <ns3:response> <ns3:opGetContentUrl_1_0> <ns2:documentContentUrl>https://server.domain.com/ACS/servlet/someUrl</ns2:documentContentUrl> </ns3:opGetContentUrl_1_0> </ns3:response> </ns3:entDocumentResponse>'; // situation 1 $xml = new \DOMDocument(); $xml->loadXML($str); $xpath = new \DOMXPath($xml, false); $xpath->registerNamespace('ns3', 'http://domain.com/services/entityService/document/1.0'); $xpath->registerNamespace('ns2', 'http://domain.com/services/entityService/document/GetContentUrl_1_0'); $res = $xpath->evaluate('/ns3:entDocumentResponse/ns3:response/ns3:opGetContentUrl_1_0/ns2:documentContentUrl'); if ($res instanceof \DOMNodeList && $res->length > 0) echo '[1] ', $res->item(0)->nodeValue, "\n"; else echo '[1] ', 'Not parsed for situation 1.', "\n"; // situation 2 $xml2 = new \DOMDocument(); $xml2->loadXML($str); $xpath2 = new \DOMXPath($xml2, false); $xpath2->registerNamespace('ns2', 'http://domain.com/services/entityService/document/1.0'); $xpath2->registerNamespace('ns3', 'http://domain.com/services/entityService/document/GetContentUrl_1_0'); $res = $xpath2->evaluate('/ns2:entDocumentResponse/ns2:response/ns2:opGetContentUrl_1_0/ns3:documentContentUrl'); if ($res instanceof \DOMNodeList && $res->length > 0) echo '[2] ', $res->item(0)->nodeValue, "\n"; else echo '[2] ', 'Not parsed for situation 2.', "\n"; // situation 3 $xml3 = new \DOMDocument(); $xml3->loadXML($str); $xpath3 = new \DOMXPath($xml3, false); $xpath3->registerNamespace('a', 'http://domain.com/services/entityService/document/1.0'); $xpath3->registerNamespace('b', 'http://domain.com/services/entityService/document/GetContentUrl_1_0'); $res = $xpath3->evaluate('/a:entDocumentResponse/a:response/a:opGetContentUrl_1_0/b:documentContentUrl'); if ($res instanceof \DOMNodeList && $res->length > 0) echo '[3] ', $res->item(0)->nodeValue, "\n"; else echo '[3] ', 'Not parsed for situation 3.', "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 38
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 46) Position 1 = 66, Position 2 = 69
Branch analysis from position: 66
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 78
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
2 jumps found. (Code = 46) Position 1 = 106, Position 2 = 109
Branch analysis from position: 106
2 jumps found. (Code = 43) Position 1 = 110, Position 2 = 118
Branch analysis from position: 110
1 jumps found. (Code = 42) Position 1 = 121
Branch analysis from position: 121
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 118
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 109
Branch analysis from position: 78
2 jumps found. (Code = 46) Position 1 = 106, Position 2 = 109
Branch analysis from position: 106
Branch analysis from position: 109
Branch analysis from position: 69
Branch analysis from position: 38
2 jumps found. (Code = 46) Position 1 = 66, Position 2 = 69
Branch analysis from position: 66
Branch analysis from position: 69
Branch analysis from position: 29
filename:       /in/ZOANr
function name:  (null)
number of ops:  122
compiled vars:  !0 = $str, !1 = $xml, !2 = $xpath, !3 = $res, !4 = $xml2, !5 = $xpath2, !6 = $xml3, !7 = $xpath3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3Cns3%3AentDocumentResponse+xmlns%3D%22http%3A%2F%2Fdomain.com%2Fdictionary%2Ftechnical%2F%22+%0A+++++xmlns%3Ans2%3D%22http%3A%2F%2Fdomain.com%2Fservices%2FentityService%2Fdocument%2FGetContentUrl_1_0%22+%0A+++++xmlns%3Ans3%3D%22http%3A%2F%2Fdomain.com%2Fservices%2FentityService%2Fdocument%2F1.0%22%3E%0A++++%3Cactivities%2F%3E%0A++++%3Cns3%3Aresponse%3E%0A++++++++%3Cns3%3AopGetContentUrl_1_0%3E%0A++++++++++++%3Cns2%3AdocumentContentUrl%3Ehttps%3A%2F%2Fserver.domain.com%2FACS%2Fservlet%2FsomeUrl%3C%2Fns2%3AdocumentContentUrl%3E%0A++++++++%3C%2Fns3%3AopGetContentUrl_1_0%3E%0A++++%3C%2Fns3%3Aresponse%3E%0A%3C%2Fns3%3AentDocumentResponse%3E'
   14     1        NEW                                              $9      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $9
   15     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   16     7        NEW                                              $13     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        SEND_VAL_EX                                              <false>
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $13
   17    12        INIT_METHOD_CALL                                         !2, 'registerNamespace'
         13        SEND_VAL_EX                                              'ns3'
         14        SEND_VAL_EX                                              'http%3A%2F%2Fdomain.com%2Fservices%2FentityService%2Fdocument%2F1.0'
         15        DO_FCALL                                      0          
   18    16        INIT_METHOD_CALL                                         !2, 'registerNamespace'
         17        SEND_VAL_EX                                              'ns2'
         18        SEND_VAL_EX                                              'http%3A%2F%2Fdomain.com%2Fservices%2FentityService%2Fdocument%2FGetContentUrl_1_0'
         19        DO_FCALL                                      0          
   19    20        INIT_METHOD_CALL                                         !2, 'evaluate'
         21        SEND_VAL_EX                                              '%2Fns3%3AentDocumentResponse%2Fns3%3Aresponse%2Fns3%3AopGetContentUrl_1_0%2Fns2%3AdocumentContentUrl'
         22        DO_FCALL                                      0  $18     
         23        ASSIGN                                                   !3, $18
   20    24        INSTANCEOF                                       ~20     !3, 'DOMNodeList'
         25      > JMPZ_EX                                          ~20     ~20, ->29
         26    >   FETCH_OBJ_R                                      ~21     !3, 'length'
         27        IS_SMALLER                                       ~22     0, ~21
         28        BOOL                                             ~20     ~22
         29    > > JMPZ                                                     ~20, ->38
   21    30    >   ECHO                                                     '%5B1%5D+'
         31        INIT_METHOD_CALL                                         !3, 'item'
         32        SEND_VAL_EX                                              0
         33        DO_FCALL                                      0  $23     
         34        FETCH_OBJ_R                                      ~24     $23, 'nodeValue'
         35        ECHO                                                     ~24
         36        ECHO                                                     '%0A'
   20    37      > JMP                                                      ->41
   23    38    >   ECHO                                                     '%5B1%5D+'
         39        ECHO                                                     'Not+parsed+for+situation+1.'
         40        ECHO                                                     '%0A'
   26    41    >   NEW                                              $25     'DOMDocument'
         42        DO_FCALL                                      0          
         43        ASSIGN                                                   !4, $25
   27    44        INIT_METHOD_CALL                                         !4, 'loadXML'
         45        SEND_VAR_EX                                              !0
         46        DO_FCALL                                      0          
   28    47        NEW                                              $29     'DOMXPath'
         48        SEND_VAR_EX                                              !4
         49        SEND_VAL_EX                                              <false>
         50        DO_FCALL                                      0          
         51        ASSIGN                                                   !5, $29
   29    52        INIT_METHOD_CALL                                         !5, 'registerNamespace'
         53        SEND_VAL_EX                                              'ns2'
         54        SEND_VAL_EX                                              'http%3A%2F%2Fdomain.com%2Fservices%2FentityService%2Fdocument%2F1.0'
         55        DO_FCALL                                      0          
   30    56        INIT_METHOD_CALL                                         !5, 'registerNamespace'
         57        SEND_VAL_EX                                              'ns3'
         58        SEND_VAL_EX                                              'http%3A%2F%2Fdomain.com%2Fservices%2FentityService%2Fdocument%2FGetContentUrl_1_0'
         59        DO_FCALL                                      0          
   31    60        INIT_METHOD_CALL                                         !5, 'evaluate'
         61        SEND_VAL_EX                                              '%2Fns2%3AentDocumentResponse%2Fns2%3Aresponse%2Fns2%3AopGetContentUrl_1_0%2Fns3%3AdocumentContentUrl'
         62        DO_FCALL                                      0  $34     
         63        ASSIGN                                                   !3, $34
   32    64        INSTANCEOF                                       ~36     !3, 'DOMNodeList'
         65      > JMPZ_EX                                          ~36     ~36, ->69
         66    >   FETCH_OBJ_R                                      ~37     !3, 'length'
         67        IS_SMALLER                                       ~38     0, ~37
         68        BOOL                                             ~36     ~38
         69    > > JMPZ                                                     ~36, ->78
   33    70    >   ECHO                                                     '%5B2%5D+'
         71        INIT_METHOD_CALL                                         !3, 'item'
         72        SEND_VAL_EX                                              0
         73        DO_FCALL                                      0  $39     
         74        FETCH_OBJ_R                                      ~40     $39, 'nodeValue'
         75        ECHO                                                     ~40
         76        ECHO                                                     '%0A'
   32    77      > JMP                                                      ->81
   35    78    >   ECHO                                                     '%5B2%5D+'
         79        ECHO                                                     'Not+parsed+for+situation+2.'
         80        ECHO                                                     '%0A'
   38    81    >   NEW                                              $41     'DOMDocument'
         82        DO_FCALL                                      0          
         83        ASSIGN                                                   !6, $41
   39    84        INIT_METHOD_CALL                                         !6, 'loadXML'
         85        SEND_VAR_EX                                              !0
         86        DO_FCALL                                      0          
   40    87        NEW                                              $45     'DOMXPath'
         88        SEND_VAR_EX                                              !6
         89        SEND_VAL_EX                                              <false>
         90        DO_FCALL                                      0          
         91        ASSIGN                                                   !7, $45
   41    92        INIT_METHOD_CALL                                         !7, 'registerNamespace'
         93        SEND_VAL_EX                                              'a'
         94        SEND_VAL_EX                                              'http%3A%2F%2Fdomain.com%2Fservices%2FentityService%2Fdocument%2F1.0'
         95        DO_FCALL                                      0          
   42    96        INIT_METHOD_CALL                                         !7, 'registerNamespace'
         97        SEND_VAL_EX                                              'b'
         98        SEND_VAL_EX                                              'http%3A%2F%2Fdomain.com%2Fservices%2FentityService%2Fdocument%2FGetContentUrl_1_0'
         99        DO_FCALL                                      0          
   43   100        INIT_METHOD_CALL                                         !7, 'evaluate'
        101        SEND_VAL_EX                                              '%2Fa%3AentDocumentResponse%2Fa%3Aresponse%2Fa%3AopGetContentUrl_1_0%2Fb%3AdocumentContentUrl'
        102        DO_FCALL                                      0  $50     
        103        ASSIGN                                                   !3, $50
   44   104        INSTANCEOF                                       ~52     !3, 'DOMNodeList'
        105      > JMPZ_EX                                          ~52     ~52, ->109
        106    >   FETCH_OBJ_R                                      ~53     !3, 'length'
        107        IS_SMALLER                                       ~54     0, ~53
        108        BOOL                                             ~52     ~54
        109    > > JMPZ                                                     ~52, ->118
   45   110    >   ECHO                                                     '%5B3%5D+'
        111        INIT_METHOD_CALL                                         !3, 'item'
        112        SEND_VAL_EX                                              0
        113        DO_FCALL                                      0  $55     
        114        FETCH_OBJ_R                                      ~56     $55, 'nodeValue'
        115        ECHO                                                     ~56
        116        ECHO                                                     '%0A'
   44   117      > JMP                                                      ->121
   47   118    >   ECHO                                                     '%5B3%5D+'
        119        ECHO                                                     'Not+parsed+for+situation+3.'
        120        ECHO                                                     '%0A'
        121    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.75 ms | 1020 KiB | 13 Q