HtmlAgilityPack SelectNode没有';t适用于WP8.1
本文关键字:适用于 WP8 SelectNode 没有 HtmlAgilityPack | 更新日期: 2023-09-27 18:00:21
在我的控制台项目中,它运行得很好。。。但当我在windowsphone 8.1上制作时,它不起作用。怎么了?
HtmlNodeCollection NoAltElements = HD.DocumentNode.SelectNodes("//div[@class='f2p-card']//div[@class='champion-info']//a[@href]");
HtmlNodeCollection NoAltElements = HD.DocumentNode.SelectNodes("//div[@class='white-stone']//a[@href]");
"我试图在WP8.1上制作.SelectsNodes(),但不明白如果XPath在WP8.1中不支持,我该怎么做"
当HtmlAgilityPack(HAP)XPath API不可用时,常见的替代方案是LINQ API,例如:
IEnumerable<HtmlNode> NoAltElements =
HD.DocumentNode
.Descendants("div")
.Where(o => o.GetAttributeValue("class", "") == "f2p-card")
.SelectMany(o => o.Descendants("div"))
.Where(o => o.GetAttributeValue("class", "") == "champion-info")
.SelectMany(o => o.Descendants("a"))
.Where(o => o.GetAttributeValue("href", null) != null);
IEnumerable<HtmlNode> NoAltElements =
HD.DocumentNode
.Descendants("div")
.Where(o => o .GetAttributeValue("class","") == "white-stone")
.SelectMany(o => o.Descendants("a"))
.Where(o => o .GetAttributeValue("href",null) != null);