3v4l.org

run code in 300+ PHP versions simultaneously
<?php //a URL you want to retrieve $my_url = 'http://www.digg.com'; $html = file_get_contents($my_url); $dom = new DOMDocument(); $dom->loadHTML($html); $xpath = new DOMXPath($dom); //Put your XPath Query here $my_xpath_query = "/html/body/span[./preceding-sibling::span[@itemprop='currency']]"; $result_rows = $xpath->query($my_xpath_query); //here we loop through our results (a DOMDocument Object) foreach ($result_rows as $result_object){ echo $result_object->childNodes->item(0)->nodeValue; }

preferences:
68.74 ms | 402 KiB | 5 Q