HTMLAgilityPack XPath syntax to extract URL from HTMLNode?

c# html-agility-pack xpath

Question

What is the proper XPath syntax to grab the value of the href attribute from the following HTMLNode:

<a target="_blank" class="monkeys" href="http://someurl.com" id="123">
    <span class="title">Monkeys are flying all over!</span>
</a> 
1
0
8/27/2010 8:56:32 PM

Accepted Answer

//a[@id='123']/@href

works for me.

3
8/27/2010 9:08:04 PM

Popular Answer

Is //a@href what you're looking for?

Using HTMLAgilityPack, the method you'd use is:

HTMLAgilityPack.HTMLNode.GetAttributeValue("href", "")


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