I've got the following code snippet and would like to retrieve the value of an attribute by including it in the XPath expression:
foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//a/@href"))
{
HtmlAttribute attr = node as HtmlAttribute;
if (attr != null)
{
return attr.Value;
}
}
But the compiler complains it can never cast an HtmlNode to an HtmlAttribute. With XML, that should work just fine IIRC. How does it work with your Html* classes?