#StackBounty: #php #xpath How exclude html comments from text node xpath?

Bounty: 50

I have the follow html structure:

<a>
    
text node 1
text node 2
</div> </a>

With the follow query, i get second node, but how get that node excluding comments?

$spanx = $xpath->query('//a/div/div/span/text()[2]');
$span = $spanx->item($l)->nodeValue;
echo "<td>".$span."</td></tr>";

I have that result:

text node 2 //comments

I search for:

text node 2


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.