Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: Selecting all nodes containing text()

$
0
0
Hello,

I have been struggling to resolve this problem I am having over the past couple of days. Say, I want to get all the text() from an HTMLdocument, however I only want to know and retrieve of the node that contains text. Example:

foreach (var textNode in node.SelectNodes(".//text()"))
//do stuff here

However, when it comes to retrieving the XPath of the textNode, I get the full XPath including the text node:

/html[1]/body[1]/div[1]/a[1]/#text

Yet I only want the containing node of the text, for example:

/html[1]/body[1]/div[1]/a[1]

Could anyone point me toward a better XPath solution to retrieve all nodes that contains text but only retrieve the XPath up until the containing node?

Thanks

Viewing all articles
Browse latest Browse all 655

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>