Reputation: 397
It is possible to convert XPathNavigator
to HtmlNode
?
Here is the code:
public string ContentByName(string name)
{
if (name == null)
throw new ArgumentNullException("name");
XPathExpression expr = _CreateXPathExpression(String.Format("//meta[@name[Extensions:CaseInsensitiveComparison('{0}')]]", name));
XPathNodeIterator it = _headNav.Select(expr);
if (!it.MoveNext())
return null;
XPathNavigator node = it.Current;
// How should I transform XPathNavigator node to HtmlNode here?
}
Upvotes: 1
Views: 911
Reputation: 53699
'it.Current' in your example returns an instance of HtmlNodeNavigator
which has a CurrentNode
property which in turn returns the HtmlNode
.
For example
HtmlNodeNavigator nodeNavigator = it.Current as HtmlNodeNavigator;
HtmlNode node = nodeNavigator.CurrentNode;
Upvotes: 1