Since Windows Phone 8.1 does not yet support HTMLAgilityPack, explicitly mentioning it in the project was a workaround. However, this is not the only issue. I could need
to choose nodes for my previous project. I can see that now.
performs no longer (because of version compatibility may be).
What I used in my previous project was comparable to this.
HtmlNode parent = document.DocumentNode.SelectSingleNode("//ul[@class='songs-list1']"); HtmlNodeCollection x = parent.ChildNodes;
I discovered via my research on stackoverflow and google that Linq may still be used to choose nodes.
I'm looking for a piece of code that functions like
Asynchronously is preferred.
This will work if you wanted to convert your existing XPath-based code to LINQ:
HtmlNode parent = document.DocumentNode .Descendants("ul") .FirstOrDefault(o => o.GetAttributeValue("class", "") == "songs-list1") HtmlNodeCollection x = parent.ChildNodes;
However, you'd best not expect to discover any XPath-accepting methods in the HTMLAgilityPack version for Windows RT or Windows Phone 8.1 universal applications ("I'm looking for a piece of code that functions like
SelectNode"): Metro Apps for Windows 8 and HTMLAgilityPack (answer by the author of HAP).
Using the Element/s approach, you can achieve it:
HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(htmlString); var h6Nodes = from h6element in doc.DocumentNode.Element("body").Element("center").Elements("h6") where h6element.Attributes["class"].Value.Equals("songs-list") select h6element;
Assuming you have anything comparable,
string htmlString = @"<html> <body> <center> <h6>Hello </h6> <h6>World! </h6> <h6 class=""songs-list""> Insert that one song here </h6> </center> </body> </html>"
also obtaining the
node containing a list of class songs.