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"; } } } } ?>
Output for git.master, git.master_jit, rfc.property-hooks
Price = £5000 Sector = IT Sector = ICT

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
50.78 ms | 401 KiB | 8 Q