HtmlAgilityPack.HtmlNode 没有 SelectNodes 的定义 [英] HtmlAgilityPack.HtmlNode no definition for SelectNodes
本文介绍了HtmlAgilityPack.HtmlNode 没有 SelectNodes 的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 HtmlAgilityPack 来查找网站中的元素.我的问题如下:
I am trying to use the HtmlAgilityPack to finds elements within a website. My Problem is the following:
我创建了一个 Windows 8 通用应用程序 (c#)
I created a Windows 8 universal app (c#)
使用我添加的 NuGet 管理器:
With the NuGet Manager I added:
using System.Net.Http;
using HtmlAgilityPack;
然后我做到了:
string htmlPage;
using (var client = new HttpClient())
{
htmlPage = await client.GetStringAsync("http://www.domain.de/");
}
HtmlDocument myDocument = new HtmlDocument();
myDocument.LoadHtml(htmlPage);
//this line results an error @ "SelectNodes"
var metaTags = myDocument.DocumentNode.SelectNodes("//meta");
但视觉工作室说:
Error 1 'HtmlAgilityPack.HtmlNode' does not contain a definition for 'SelectNodes'
我已经用谷歌搜索了这个问题,但所有网站都解决了另一个问题,其中代码显示DocumentElement"而不是DocumentNode".
I already googled the problem but all websites just solved another problem where the code said "DocumentElement" instead of "DocumentNode".
你有什么提示吗?
谢谢!
推荐答案
是的,SelectNodes
在 WP8 上不可用,但您可以使用;
Yes, SelectNodes
is not available on WP8 but you can use;
var metaTags = myDocument.DocumentNode.Descendants("meta");
相反.
这篇关于HtmlAgilityPack.HtmlNode 没有 SelectNodes 的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文