3v4l.org

run code in 300+ PHP versions simultaneously
<?php // from your file $xml = ' <div class="DetailsPanel"> <label class="ListLabel left">Location</label> <span id="location" class="ListDetail left" title="London, UK">London, UK</span> <label class="ListLabel left">Price</label> <span id="price" class="ListDetail left" title="£5000">£5000</span> <label class="ListLabel left">Sector</label> <span class="ListDetail left"> <a href="/">IT</a> <a href="/">ICT</a> </span> </div> '; $xmldoc = new DOMDocument(); //$xmldoc->load('yourFile.html'); $xmldoc->loadXML($xml); $xpath = new Domxpath($xmldoc); foreach($xpath->query("//div") as $node){ //$tag = $node->getAttribute('id'); $string = $node->nodeValue; //echo $string . '|'; foreach($xpath->query("//div/label") as $node1){ $string = $node1->nodeValue; //echo $string . "\n"; if($string === 'Sector') { foreach ($xpath->query("//div/span/a") as $sector) { $string = $sector->nodeValue; echo "Sector = " . $string . "\n"; } } if($string === 'Price') { foreach ($xpath->query("//div/span[@id='price']") as $price) { $string = $price->nodeValue; echo "Price = " . $string . "\n"; } } } } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 56
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 56
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 54
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 54
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 39
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 38
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 38
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 53
Branch analysis from position: 41
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 52
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 52
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 52
Branch analysis from position: 53
Branch analysis from position: 38
Branch analysis from position: 39
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 54
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
filename:       /in/IBYFF
function name:  (null)
number of ops:  58
compiled vars:  !0 = $xml, !1 = $xmldoc, !2 = $xpath, !3 = $node, !4 = $string, !5 = $node1, !6 = $sector, !7 = $price
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, '%0A%3Cdiv+class%3D%22DetailsPanel%22%3E%0A++++%3Clabel+class%3D%22ListLabel+left%22%3ELocation%3C%2Flabel%3E%0A++++%3Cspan+id%3D%22location%22+class%3D%22ListDetail+left%22+title%3D%22London%2C+UK%22%3ELondon%2C+UK%3C%2Fspan%3E%0A+++++%3Clabel+class%3D%22ListLabel+left%22%3EPrice%3C%2Flabel%3E%0A++++%3Cspan+id%3D%22price%22+class%3D%22ListDetail+left%22+title%3D%22%C2%A35000%22%3E%C2%A35000%3C%2Fspan%3E%0A++++%3Clabel+class%3D%22ListLabel+left%22%3ESector%3C%2Flabel%3E%0A++++%3Cspan+class%3D%22ListDetail+left%22%3E%0A++++++%3Ca+href%3D%22%2F%22%3EIT%3C%2Fa%3E%0A++++++%3Ca+href%3D%22%2F%22%3EICT%3C%2Fa%3E%0A++++%3C%2Fspan%3E%0A%3C%2Fdiv%3E%0A%0A'
   20     1        NEW                                              $9      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $9
   22     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   24     7        NEW                                              $13     'Domxpath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $13
   26    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2Fdiv'
         13        DO_FCALL                                      0  $16     
         14      > FE_RESET_R                                       $17     $16, ->56
         15    > > FE_FETCH_R                                               $17, !3, ->56
   29    16    >   FETCH_OBJ_R                                      ~18     !3, 'nodeValue'
         17        ASSIGN                                                   !4, ~18
   32    18        INIT_METHOD_CALL                                         !2, 'query'
         19        SEND_VAL_EX                                              '%2F%2Fdiv%2Flabel'
         20        DO_FCALL                                      0  $20     
         21      > FE_RESET_R                                       $21     $20, ->54
         22    > > FE_FETCH_R                                               $21, !5, ->54
   33    23    >   FETCH_OBJ_R                                      ~22     !5, 'nodeValue'
         24        ASSIGN                                                   !4, ~22
   36    25        IS_IDENTICAL                                             !4, 'Sector'
         26      > JMPZ                                                     ~24, ->39
   37    27    >   INIT_METHOD_CALL                                         !2, 'query'
         28        SEND_VAL_EX                                              '%2F%2Fdiv%2Fspan%2Fa'
         29        DO_FCALL                                      0  $25     
         30      > FE_RESET_R                                       $26     $25, ->38
         31    > > FE_FETCH_R                                               $26, !6, ->38
   38    32    >   FETCH_OBJ_R                                      ~27     !6, 'nodeValue'
         33        ASSIGN                                                   !4, ~27
   39    34        CONCAT                                           ~29     'Sector+%3D+', !4
         35        CONCAT                                           ~30     ~29, '%0A'
         36        ECHO                                                     ~30
   37    37      > JMP                                                      ->31
         38    >   FE_FREE                                                  $26
   43    39    >   IS_IDENTICAL                                             !4, 'Price'
         40      > JMPZ                                                     ~31, ->53
   44    41    >   INIT_METHOD_CALL                                         !2, 'query'
         42        SEND_VAL_EX                                              '%2F%2Fdiv%2Fspan%5B%40id%3D%27price%27%5D'
         43        DO_FCALL                                      0  $32     
         44      > FE_RESET_R                                       $33     $32, ->52
         45    > > FE_FETCH_R                                               $33, !7, ->52
   45    46    >   FETCH_OBJ_R                                      ~34     !7, 'nodeValue'
         47        ASSIGN                                                   !4, ~34
   46    48        CONCAT                                           ~36     'Price+%3D+', !4
         49        CONCAT                                           ~37     ~36, '%0A'
         50        ECHO                                                     ~37
   44    51      > JMP                                                      ->45
         52    >   FE_FREE                                                  $33
   32    53    > > JMP                                                      ->22
         54    >   FE_FREE                                                  $21
   26    55      > JMP                                                      ->15
         56    >   FE_FREE                                                  $17
   56    57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.56 ms | 1399 KiB | 13 Q