Select a node with a certain text value using htmlagilitypack

c# html-agility-pack hyperlink screen-scraping

Question

I am thus aware of the htmlagilitypack node selection process:

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

etc., but let's pretend I have a website set up 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...

The excerpt is currently brief, but essentially, I only want to visit URLs that contain the text value.

"this is information i want to get to"

(Sorry, I don't know enough about hmtl to use right language.) Is there a way for me to verify the text value in htmlagilitypack?

I'm grateful.

1
6
6/18/2012 2:37:46 PM

Accepted Answer

Utilize thetext() function:

SelectNodes("a[text()='This is information i want to get to']")
15
6/18/2012 2:40:55 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow