Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

As HtmlAgilityPack is yet not supported in windows phone 8.1,referencing manually in the project was a trick solution. But this is not the only problem. I could use XPath for my past project to select nodes. Now I can see that HtmlDocumentNode.SelectNode() function is no more(because of version compatibility may be).

what I used in my past project was similar to this

HtmlNode parent = document.DocumentNode.SelectSingleNode("//ul[@class='songs-list1']");
HtmlNodeCollection x = parent.ChildNodes;

I searched over stackoverflow and google and got an Idea that It's still possible to select nodes using Linq.

I'm seeking for a block of code which will work like SelectNodes, SelectNode.

Loading the HtmlDocument asynchronously would be appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
232 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you meant to translate your current code which using XPath to be using LINQ, then this will do :

HtmlNode parent = document.DocumentNode
                          .Descendants("ul")
                          .FirstOrDefault(o => o.GetAttributeValue("class", "") 
                                                   == "songs-list1")
HtmlNodeCollection x = parent.ChildNodes;

But if you expect to find methods that accept XPath in HtmlAgilityPack version for Windows Phone 8.1 universal apps or Windows RT ("I'm seeking for a block of code which will work like SelectNodes, SelectNode"), you better don't : HtmlAgilityPack & Windows 8 Metro Apps (answer by the author of HAP).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...