Let’s say I have this code:
<p dataname="description">
Hello this is a description. <a href="#">Click here for more.</a>
</p>
How do I select the nodeValue of p but exclude a and it’s content?
My current code:
$result = $xpath->query("//p[@dataname='description'][not(self::a)]");
I select it by $result->item(0)->nodeValue;
Simply appending /text() to your query should do the trick