我试图让HtmlAgilityPack与Windows 8 Metro应用程序(Windows应用商店应用程序)配合使用。我已经成功地在Windows控制台应用程序(C#)中写出了我需要的所有代码,并且它完美地解析了我需要的HTML,并将我需要的所需字符串返回给我。HtmlAgilityPack和Windows 8 Metro应用程序
// Create a new HtmlDocument and load the incoming string
HtmlDocument menu = new HtmlDocument();
menu.OptionUseIdAttribute = true;
menu.LoadHtml(response);
HtmlNode nameToRemove = menu.DocumentNode.SelectSingleNode("//*[@id=\"maincontent_0_contentplaceholder_0_lblHall\"]");
我的问题是与DocumentNode.SelectSingleNode
调用。我收到以下错误:
Error 2 'HtmlAgilityPack.HtmlNode' does not contain a definition for 'SelectSingleNode' and no extension method 'SelectSingleNode' accepting a first argument of type 'HtmlAgilityPack.HtmlNode' could be found (are you missing a using directive or an assembly reference?)
我证实,我把所有的引用设置的确切方法,我在控制台应用程序做同样的,但我无法得到这个工作。根据HtmlAgilityPack twitter帐户,在版本1.4.5中添加了对Windows 8 Metro/Windows Phone 8的支持。我再次检查我的NuGet包管理器,并且我安装了1.4.6。
在Windows 8应用程序的HtmlDocument中,我需要做些什么来选择节点XPath
?任何建议将不胜感激。
谢谢!
编辑:任何人都可以帮我获得与Linq查询相同的结果,然后。我不确定我会怎么做。
请检查[Metro版本和SelectNodes](https://htmlagilitypack.codeplex.com/discussions/359358)&[HtmlAgilityPack和Windows 8 winRT](http://stackoverflow.com/questions/12829137/htmlagilitypack-and -windows-8-winrt) – Xyroid 2013-04-11 06:04:13
任何人都可以帮我用Linq查询获得相同的结果。我不确定我会怎么做。 – 2013-04-11 06:08:47