HeyAlex
HeyAlex

Reputation: 1746

HtmlAgilityPack SelectNode doesn't works on WP8.1

On my console project, it's works great...but when i make it on windows phone 8.1, it does not work. What's the problem?

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]");

Upvotes: 0

Views: 141

Answers (1)

har07
har07

Reputation: 89305

"im trying to make .SelectsNodes() on WP8.1, but cant understand how can i do this if XPath doesnt support on WP8.1"

Common alternative when HtmlAgilityPack (HAP) XPath API not available is LINQ API, for example :

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);

Upvotes: 1

Related Questions