I want to parse <a href=""></a>
tag of a website. I am trying to get the href attribute value present in each of such 'description' span classes.
I tried the following code
HtmlNodeCollection sp = htmlDocument.DocumentNode.SelectNodes("//span[@class='description']//a");
foreach (HtmlNode link in sp)
{
HtmlAttribute att = link.Attributes["href"];
System.Diagnostics.Debug.WriteLine(att.Value);
}
I am not able to get the href attribute value. What is my mistake ?
You can use chrome developer tools (F12), it can help you easy to get correct xPath syntax (Copy XPath)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.