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> <label class="ListLabel left">Location</label> <span id="location" class="ListDetail left" title="London, UK">Derby, UK</span> <label class="ListLabel left">Price</label> <span id="price" class="ListDetail left" title="£1000">£1000</span> <label class="ListLabel left">Sector</label> <span class="ListDetail left"> <a href="/">Finance</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 = 53
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 53
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 51
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 51
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 = 50
Branch analysis from position: 41
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 49
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 49
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 49
Branch analysis from position: 50
Branch analysis from position: 38
Branch analysis from position: 39
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 51
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
filename:       /in/iYsps
function name:  (null)
number of ops:  55
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%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%3EDerby%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%A31000%22%3E%C2%A31000%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%3EFinance%3C%2Fa%3E%0A++++%3C%2Fspan%3E%0A%3C%2Fdiv%3E%0A%0A'
   29     1        NEW                                              $9      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $9
   31     4        INIT_METHOD_CALL                                         !1, 'loadXML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   33     7        NEW                                              $13     'Domxpath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $13
   35    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2Fdiv'
         13        DO_FCALL                                      0  $16     
         14      > FE_RESET_R                                       $17     $16, ->53
         15    > > FE_FETCH_R                                               $17, !3, ->53
   38    16    >   FETCH_OBJ_R                                      ~18     !3, 'nodeValue'
         17        ASSIGN                                                   !4, ~18
   41    18        INIT_METHOD_CALL                                         !2, 'query'
         19        SEND_VAL_EX                                              '%2F%2Fdiv%2Flabel'
         20        DO_FCALL                                      0  $20     
         21      > FE_RESET_R                                       $21     $20, ->51
         22    > > FE_FETCH_R                                               $21, !5, ->51
   42    23    >   FETCH_OBJ_R                                      ~22     !5, 'nodeValue'
         24        ASSIGN                                                   !4, ~22
   45    25        IS_IDENTICAL                                             !4, 'Sector'
         26      > JMPZ                                                     ~24, ->39
   46    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
   47    32    >   FETCH_OBJ_R                                      ~27     !6, 'nodeValue'
         33        ASSIGN                                                   !4, ~27
   48    34        CONCAT                                           ~29     'Sector+%3D+', !4
         35        CONCAT                                           ~30     ~29, '%0A'
         36        ECHO                                                     ~30
   46    37      > JMP                                                      ->31
         38    >   FE_FREE                                                  $26
   52    39    >   IS_IDENTICAL                                             !4, 'Price'
         40      > JMPZ                                                     ~31, ->50
   53    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, ->49
         45    > > FE_FETCH_R                                               $33, !7, ->49
   54    46    >   FETCH_OBJ_R                                      ~34     !7, 'nodeValue'
         47        ASSIGN                                                   !4, ~34
   53    48      > JMP                                                      ->45
         49    >   FE_FREE                                                  $33
   41    50    > > JMP                                                      ->22
         51    >   FE_FREE                                                  $21
   35    52      > JMP                                                      ->15
         53    >   FE_FREE                                                  $17
   65    54      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.37 ms | 1399 KiB | 13 Q