I have the following which prints 100 - which is correct - however, I have to use print_r() which is obviously wrong
$dom = new DOMDocument();
$dom->loadHTML('<span class="foo" id="bar" itemprop="price">100</span>');
$xpath = new DOMXPath($dom);
$results = $xpath->evaluate('number(//*[@itemprop="price"])');
print_r($results);`
So, how should I get the single result which is 100? I've tried $results[0] which didn't work.
Am sure it's simple but beating me!
print_r(), I ran your code just fine withechoinstead.