是否可以将XPathNavigator转换为HtmlNode?代码如下:
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?
}发布于 2012-02-07 01:53:31
示例中的'it.Current‘返回HtmlNodeNavigator的一个实例,该实例具有CurrentNode属性,而该属性又返回HtmlNode。
例如
HtmlNodeNavigator nodeNavigator = it.Current as HtmlNodeNavigator;
HtmlNode node = nodeNavigator.CurrentNode;https://stackoverflow.com/questions/9162448
复制相似问题