在我的控制台项目上,它的工作效果非常好...但是当我在Windows Phone 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);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句