【问题标题】:'HtmlAgilityPack.HtmlNode' does not contain a definition for 'SelectNodes'“HtmlAgilityPack.HtmlNode”不包含“SelectNodes”的定义
【发布时间】:2015-08-03 03:48:42
【问题描述】:

“HtmlAgilityPack.HtmlNode”不包含“SelectNodes”的定义,并且找不到接受“HtmlAgilityPack.HtmlNode”类型的第一个参数的扩展方法“SelectNodes”(您是否缺少 using 指令或程序集引用? )

我有如下设置配置:

这是代码!!!

HttpClient client = new HttpClient();
        string html = await client.GetStringAsync(Url);
        HtmlDocument htmlDocument = new HtmlDocument();
        htmlDocument.LoadHtml(html);
        var a =htmlDocument.DocumentNode.SelectNodes("//p[@class='verse']");

【问题讨论】:

标签: c# windows-phone html-agility-pack selectnodes


【解决方案1】:

由于缺乏可用于 WP 的 XPath 支持,Windows Phone 的 HAP 版本不公开 SelectNodes() 方法。您需要使用 HAP LINQ API 来做同样的事情:

var a = htmlDocument.DocumentNode
                    .Descendants("p")
                    .Where(p => p.GetAttributeValue("class","") == "verse");

【讨论】:

  • 转到文件 .dll 右键单击​​ => 属性=> 取消阻止只需添加成功
猜你喜欢
  • 2015-03-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多