Select a node with a specific text value using htmlagilitypack

So, I know how to select node using htmlagilitypack:

HtmlNode.SelectNodes(".//div[@class='description']") 

etc .... but I will say that I have a website created as follows:

 <a href="/link1/">This is Link 1</a> <a href="/link2/">This is information i want to get to</a> <a href="/link3/">This is Link 3</a> <a href="/link4/">This is information i want to get to</a> <a href="/link5/">This is Link 5</a> <a href="/link6/">This is Link 6</a> 

etc...

Now the fragment is short, but basically, the links are asymmetric, and I want to access the links with a text value

"this is the information I want to get"

(I'm not familiar enough with hmtl to use the correct terminology here, sorry). Is there a way in htmlagilitypack where I can check this text value?

Thanks!

+4
source share
1 answer

Try using the text() function:

 SelectNodes("a[text()='This is information i want to get to']") 
+13
source

All Articles