I'm getting a Call to undefined method DOMDocument::xpath()
on the $level1
line of my code:
$doc = new DOMDocument();
$doc->strictErrorChecking = FALSE;
$doc->loadHTML($html);
$xml = simplexml_import_dom($doc);
$level1 = $doc->xpath('//*[contains(concat(" ", normalize-space(@class), " "), " category-wrap ")]/h2/a');
Here is the html it's loading (via file_get_contents()
):
<div class="category-wrap">
<a href='#'>LINK</a>
<h2><a href="#">Trying to get this....</a></h2>
<p>A description</p>
</div>
I'm using this answer as a reference for the xpath query.
What is wrong with my query?