3v4l.org

run code in 300+ PHP versions simultaneously
<?php $content = <<<XML <?xml version="1.0" encoding="ISO-8859-1"?> <PersonList> <header> </header> <Person> <Name>Sonu Kapoor</Name> <Age>24</Age> <Gender>M</Gender> <PostalCode>54879</PostalCode> </Person> <Person> <Name>Jasmin</Name> <Age>28</Age> <Gender>M</Gender> <PostalCode>78745</PostalCode> </Person> <Person> <Name>Josef</Name> <Age>232</Age> <Gender>F</Gender> <PostalCode>53454</PostalCode> </Person> </PersonList> XML; $doc = new DOMDocument(); $doc->loadXML($content); $xp = new DOMXPath($doc); $nodeList = $xp->query('/PersonList/Person[./Name="Jasmin"]/*'); for($i = 0; $i < $nodeList->length; $i++) { $nodeName = $nodeList->item($i)->nodeName; switch ($nodeName) { case 'Age': $nodeList->item($i)->nodeValue = 33; break; case 'Gender': $nodeList->item($i)->nodeValue = 'F'; break; } } $doc->formatOutput = true; echo $doc->saveXML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 17
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
4 jumps found. (Code = 188) Position 1 = 28, Position 2 = 35, Position 3 = 42, Position 4 = 23
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 17
Branch analysis from position: 46
Branch analysis from position: 17
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 42
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 35
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 35
Branch analysis from position: 28
filename:       /in/9FElu
function name:  (null)
number of ops:  52
compiled vars:  !0 = $content, !1 = $doc, !2 = $xp, !3 = $nodeList, !4 = $i, !5 = $nodeName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22ISO-8859-1%22%3F%3E%0A%3CPersonList%3E%0A%3Cheader%3E%0A%3C%2Fheader%3E%0A++%3CPerson%3E%0A++++%3CName%3ESonu+Kapoor%3C%2FName%3E%0A++++%3CAge%3E24%3C%2FAge%3E%0A++++%3CGender%3EM%3C%2FGender%3E%0A++++%3CPostalCode%3E54879%3C%2FPostalCode%3E%0A++%3C%2FPerson%3E%0A++%3CPerson%3E%0A++++%3CName%3EJasmin%3C%2FName%3E%0A++++%3CAge%3E28%3C%2FAge%3E%0A++++%3CGender%3EM%3C%2FGender%3E%0A++++%3CPostalCode%3E78745%3C%2FPostalCode%3E%0A++%3C%2FPerson%3E%0A+++%3CPerson%3E%0A++++%3CName%3EJosef%3C%2FName%3E%0A++++%3CAge%3E232%3C%2FAge%3E%0A++++%3CGender%3EF%3C%2FGender%3E%0A++++%3CPostalCode%3E53454%3C%2FPostalCode%3E%0A++%3C%2FPerson%3E%0A%3C%2FPersonList%3E'
   28     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   29     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   30     7        NEW                                              $11     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $11
   31    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2FPersonList%2FPerson%5B.%2FName%3D%22Jasmin%22%5D%2F%2A'
         13        DO_FCALL                                      0  $14     
         14        ASSIGN                                                   !3, $14
   32    15        ASSIGN                                                   !4, 0
         16      > JMP                                                      ->43
   33    17    >   INIT_METHOD_CALL                                         !3, 'item'
         18        SEND_VAR_EX                                              !4
         19        DO_FCALL                                      0  $17     
         20        FETCH_OBJ_R                                      ~18     $17, 'nodeName'
         21        ASSIGN                                                   !5, ~18
   34    22      > SWITCH_STRING                                            !5, [ 'Age':->28, 'Gender':->35, ], ->42
   35    23    >   IS_EQUAL                                                 !5, 'Age'
         24      > JMPNZ                                                    ~20, ->28
   38    25    >   IS_EQUAL                                                 !5, 'Gender'
         26      > JMPNZ                                                    ~20, ->35
         27    > > JMP                                                      ->42
   36    28    >   INIT_METHOD_CALL                                         !3, 'item'
         29        SEND_VAR_EX                                              !4
         30        DO_FCALL                                      0  $21     
         31        SEPARATE                                         $21     $21
         32        ASSIGN_OBJ                                               $21, 'nodeValue'
         33        OP_DATA                                                  33
   37    34      > JMP                                                      ->42
   39    35    >   INIT_METHOD_CALL                                         !3, 'item'
         36        SEND_VAR_EX                                              !4
         37        DO_FCALL                                      0  $23     
         38        SEPARATE                                         $23     $23
         39        ASSIGN_OBJ                                               $23, 'nodeValue'
         40        OP_DATA                                                  'F'
   40    41      > JMP                                                      ->42
   32    42    >   PRE_INC                                                  !4
         43    >   FETCH_OBJ_R                                      ~26     !3, 'length'
         44        IS_SMALLER                                               !4, ~26
         45      > JMPNZ                                                    ~27, ->17
   43    46    >   ASSIGN_OBJ                                               !1, 'formatOutput'
         47        OP_DATA                                                  <true>
   44    48        INIT_METHOD_CALL                                         !1, 'saveXML'
         49        DO_FCALL                                      0  $29     
         50        ECHO                                                     $29
         51      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.18 ms | 1399 KiB | 13 Q