【发布时间】:2019-10-05 16:55:42
【问题描述】:
昨天我发布了这个问题:
https://stackoverflow.com/questions/56182368/html-agility-pack-select-node-after-particular-paragraph
我使用解决方案解决了:htmlSnippet.DocumentNode.SelectNodes('//p[text()="targetWord"]/following-sibling::ul[1]//li')
今天在另一个具有相同配置和 HTML 敏捷包版本的项目中,我收到标题中的错误消息。我能做些什么来解决它?
System.Xml.XPath.XPathException: 'Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.'
引发异常的代码:
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(htmlText);
//var ulCollection = htmlDoc.DocumentNode.SelectNodes("//ul");
var tasksNodesCollection = htmlDoc.DocumentNode.SelectNodes("//p[TextValue()=\"Paragraph:\"]/following-sibling::ul[1]//li");
【问题讨论】:
-
可以在这里找到解决方案 "stackoverflow.com/questions/13511527/…"
-
这如何应用于 html 敏捷包?
-
能否提供出错的代码
-
您需要发布回复。看起来响应是 XML,您无法使用响应 xml 创建文档
-
var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlText); //var ulCollection = htmlDoc.DocumentNode.SelectNodes("//ul"); var tasksNodesCollection = htmlDoc.DocumentNode.SelectNodes("//p[TextValue()=\"Paragraph:\"]/following-sibling::ul[1]//li");
标签: c# xml html-agility-pack