3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test($xml) { $dom = new DomDocument(); $dom->loadXML($xml); $node = $dom->documentElement; $nodes = array(); foreach($node->childNodes as $n) if($n->nodeType==XML_ELEMENT_NODE) $nodes[]=$n; foreach($nodes as $n) $n->parentNode->removeChild($n); foreach($nodes as $n) $node->appendChild($n); echo $dom->saveXML(); } test('<?xml version="1.0" encoding="UTF-8"?><test xmlns:any="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"><item /><item xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"/></test>'); test('<?xml version="1.0" encoding="UTF-8"?><test xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"><item /><item xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"/></test>');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jg9E0
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'test'
          1        SEND_VAL                                                 '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3Ctest+xmlns%3Aany%3D%22urn%3Aiso%3Astd%3Aiso%3A20022%3Atech%3Axsd%3Apain.001.001.03%22%3E%3Citem+%2F%3E%3Citem+xmlns%3D%22urn%3Aiso%3Astd%3Aiso%3A20022%3Atech%3Axsd%3Apain.001.001.03%22%2F%3E%3C%2Ftest%3E'
          2        DO_FCALL                                      0          
   14     3        INIT_FCALL                                               'test'
          4        SEND_VAL                                                 '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%3Ctest+xmlns%3D%22urn%3Aiso%3Astd%3Aiso%3A20022%3Atech%3Axsd%3Apain.001.001.03%22%3E%3Citem+%2F%3E%3Citem+xmlns%3D%22urn%3Aiso%3Astd%3Aiso%3A20022%3Atech%3Axsd%3Apain.001.001.03%22%2F%3E%3C%2Ftest%3E'
          5        DO_FCALL                                      0          
          6      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 18
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 27
Branch analysis from position: 19
filename:       /in/jg9E0
function name:  test
number of ops:  39
compiled vars:  !0 = $xml, !1 = $dom, !2 = $node, !3 = $nodes, !4 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        NEW                                              $5      'DomDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $5
    4     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
    5     7        FETCH_OBJ_R                                      ~9      !1, 'documentElement'
          8        ASSIGN                                                   !2, ~9
    6     9        ASSIGN                                                   !3, <array>
    7    10        FETCH_OBJ_R                                      ~12     !2, 'childNodes'
         11      > FE_RESET_R                                       $13     ~12, ->19
         12    > > FE_FETCH_R                                               $13, !4, ->19
         13    >   FETCH_OBJ_R                                      ~14     !4, 'nodeType'
         14        IS_EQUAL                                                 ~14, 1
         15      > JMPZ                                                     ~15, ->18
         16    >   ASSIGN_DIM                                               !3
         17        OP_DATA                                                  !4
         18    > > JMP                                                      ->12
         19    >   FE_FREE                                                  $13
    8    20      > FE_RESET_R                                       $17     !3, ->27
         21    > > FE_FETCH_R                                               $17, !4, ->27
         22    >   FETCH_OBJ_R                                      ~18     !4, 'parentNode'
         23        INIT_METHOD_CALL                                         ~18, 'removeChild'
         24        SEND_VAR_EX                                              !4
         25        DO_FCALL                                      0          
         26      > JMP                                                      ->21
         27    >   FE_FREE                                                  $17
    9    28      > FE_RESET_R                                       $20     !3, ->34
         29    > > FE_FETCH_R                                               $20, !4, ->34
         30    >   INIT_METHOD_CALL                                         !2, 'appendChild'
         31        SEND_VAR_EX                                              !4
         32        DO_FCALL                                      0          
         33      > JMP                                                      ->29
         34    >   FE_FREE                                                  $20
   10    35        INIT_METHOD_CALL                                         !1, 'saveXML'
         36        DO_FCALL                                      0  $22     
         37        ECHO                                                     $22
   11    38      > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.28 ms | 1403 KiB | 15 Q