开发者

XPath syntax to extract URL from HTMLNode using HTMLAgilityPack?

开发者 https://www.devze.com 2023-01-13 23:59 出处:网络
What is the proper XPath syntax to grab the value of the href attribute from the following HTMLNode: <开发者_JAVA百科;a target=\"_blank\" class=\"monkeys\" href=\"http://someurl.com\" id=\"123\">

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

<开发者_JAVA百科;a target="_blank" class="monkeys" href="http://someurl.com" id="123">
    <span class="title">Monkeys are flying all over!</span>
</a> 


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

works for me.


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

Using HTMLAgilityPack, the method you'd use is:

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

精彩评论

暂无评论...
验证码 换一张
取 消