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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.66 ms | 1399 KiB | 13 Q