gpt4 book ai didi

c# - HtmlAgilityPack 和 Windows 8 Metro 应用程序

转载 作者:太空狗 更新时间:2023-10-30 00:19:54 25 4
gpt4 key购买 nike

我正在尝试让 HtmlAgilityPack 与 Windows 8 Metro 应用程序(Windows 应用商店应用程序)一起使用。我已经在 Windows 控制台应用程序 (C#) 中成功地写出了我需要的所有代码,它非常适合解析我需要的 HTML 并返回我需要的字符串。

// 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 推特账号,在 1.4.5 版本中添加了对 Windows 8 Metro/Windows Phone 8 的支持。我仔细检查了我的 NuGet 包管理器,我安装了 1.4.6。

要在 Windows 8 应用程序的 HtmlDocument 中通过 XPath 选择节点,我需要做些什么特别的事情吗?任何建议将不胜感激。

谢谢!

编辑:任何人都可以帮助我使用 Linq 查询获得相同的结果吗?我不确定我会怎么做。

最佳答案

Html Agility Pack 依赖于 .NET 来实现 XPATH。不幸的是,WinRT 不支持 XPATH,因此您在 Html Agility Pack for WinRT 中没有任何与 XPATH 相关的内容。

关于c# - HtmlAgilityPack 和 Windows 8 Metro 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15941529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com