3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <cats> <cat order="first"> <name>Lucy</name> <coat>Tortoiseshell</coat> <breed>Domestic Longhair</breed> </cat> <cat order="second"> <name>Ricky</name> <coat>Gray Tabby</coat> <breed>Maine Coon mix</breed> </cat> </cats> XML; $reader = new \XMLReader(); $dom = new \DOMDocument(); $reader->open('data://text/plain,' . urlencode($xml)); while ($reader->read()) { if ($reader->nodeType === \XMLReader::ELEMENT) { if ($reader->name === 'cat') { $node = $reader->expand(); $dom->appendChild($dom->importNode($node, true)); } } } var_dump($dom);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 15
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 31
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 31
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 15
Branch analysis from position: 34
Branch analysis from position: 15
Branch analysis from position: 31
Branch analysis from position: 31
filename:       /in/KcQfj
function name:  (null)
number of ops:  38
compiled vars:  !0 = $xml, !1 = $reader, !2 = $dom, !3 = $node
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%0A%3Ccats%3E%0A++++%3Ccat+order%3D%22first%22%3E%0A++++++++%3Cname%3ELucy%3C%2Fname%3E%0A++++++++%3Ccoat%3ETortoiseshell%3C%2Fcoat%3E%0A++++++++%3Cbreed%3EDomestic+Longhair%3C%2Fbreed%3E%0A++++%3C%2Fcat%3E%0A++++%3Ccat+order%3D%22second%22%3E%0A++++++++%3Cname%3ERicky%3C%2Fname%3E%0A++++++++%3Ccoat%3EGray+Tabby%3C%2Fcoat%3E%0A++++++++%3Cbreed%3EMaine+Coon+mix%3C%2Fbreed%3E%0A++++%3C%2Fcat%3E%0A%3C%2Fcats%3E'
   19     1        NEW                                              $5      'XMLReader'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
   20     4        NEW                                              $8      'DOMDocument'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $8
   22     7        INIT_METHOD_CALL                                         !1, 'open'
          8        INIT_FCALL                                               'urlencode'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $11     
         11        CONCAT                                           ~12     'data%3A%2F%2Ftext%2Fplain%2C', $11
         12        SEND_VAL_EX                                              ~12
         13        DO_FCALL                                      0          
   24    14      > JMP                                                      ->31
   25    15    >   FETCH_OBJ_R                                      ~14     !1, 'nodeType'
         16        IS_IDENTICAL                                             ~14, 1
         17      > JMPZ                                                     ~15, ->31
   26    18    >   FETCH_OBJ_R                                      ~16     !1, 'name'
         19        IS_IDENTICAL                                             ~16, 'cat'
         20      > JMPZ                                                     ~17, ->31
   27    21    >   INIT_METHOD_CALL                                         !1, 'expand'
         22        DO_FCALL                                      0  $18     
         23        ASSIGN                                                   !3, $18
   29    24        INIT_METHOD_CALL                                         !2, 'appendChild'
         25        INIT_METHOD_CALL                                         !2, 'importNode'
         26        SEND_VAR_EX                                              !3
         27        SEND_VAL_EX                                              <true>
         28        DO_FCALL                                      0  $20     
         29        SEND_VAR_NO_REF_EX                                       $20
         30        DO_FCALL                                      0          
   24    31    >   INIT_METHOD_CALL                                         !1, 'read'
         32        DO_FCALL                                      0  $22     
         33      > JMPNZ                                                    $22, ->15
   34    34    >   INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.02 ms | 1400 KiB | 17 Q