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 id="35" atrib="LOL">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); */ $xmlIdatziDok = new DOMDocument(); $xmlIdatziDok->loadXML($content); $xPath_IdatziDok = new DOMXPath($xmlIdatziDok); foreach ($xPath_IdatziDok->query('//PersonList/Header/Person/Name') AS $Idaztekoa) { $IdaztekoaID = $Idaztekoa->getAttribute('id'); $IdaztekoaAtrib = $Idaztekoa->getAttribute('atrib'); if($IdaztekoaAtrib != "") { $Idazteko->Attribute('atrib','yes'); } } $xmlIdatziDok->formatOutput = true; echo $xmlIdatziDok->saveXML();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 31
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 31
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 30
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/5tPYY
function name:  (null)
number of ops:  38
compiled vars:  !0 = $content, !1 = $xmlIdatziDok, !2 = $xPath_IdatziDok, !3 = $Idaztekoa, !4 = $IdaztekoaID, !5 = $IdaztekoaAtrib, !6 = $Idazteko
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+id%3D%2235%22+atrib%3D%22LOL%22%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'
   34     1        NEW                                              $8      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $8
   35     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   36     7        NEW                                              $12     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $12
   38    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2FPersonList%2FHeader%2FPerson%2FName'
         13        DO_FCALL                                      0  $15     
         14      > FE_RESET_R                                       $16     $15, ->31
         15    > > FE_FETCH_R                                               $16, !3, ->31
   40    16    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         17        SEND_VAL_EX                                              'id'
         18        DO_FCALL                                      0  $17     
         19        ASSIGN                                                   !4, $17
   41    20        INIT_METHOD_CALL                                         !3, 'getAttribute'
         21        SEND_VAL_EX                                              'atrib'
         22        DO_FCALL                                      0  $19     
         23        ASSIGN                                                   !5, $19
   43    24        IS_NOT_EQUAL                                             !5, ''
         25      > JMPZ                                                     ~21, ->30
   45    26    >   INIT_METHOD_CALL                                         !6, 'Attribute'
         27        SEND_VAL_EX                                              'atrib'
         28        SEND_VAL_EX                                              'yes'
         29        DO_FCALL                                      0          
   38    30    > > JMP                                                      ->15
         31    >   FE_FREE                                                  $16
   49    32        ASSIGN_OBJ                                               !1, 'formatOutput'
         33        OP_DATA                                                  <true>
   50    34        INIT_METHOD_CALL                                         !1, 'saveXML'
         35        DO_FCALL                                      0  $24     
         36        ECHO                                                     $24
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.64 ms | 1399 KiB | 13 Q