HtmlAgilityPack and windows 8 winRT

html-agility-pack windows-runtime


I'm attempting to create a Windows 8 Metro application. I'm attempting to parse data from a webpage in this app. I'm using HtmlAgilityPack 1.4.6 for that. But I'm having a lot of trouble understanding if HAP 1.4.6 is compatible with Windows 8. likewise "Does it support Xpath?" The information on Codeplex is rather unclear. As of right now, Windows 8 seems to support it, but I am unable to view HtmlNode. Method SelectNode. Is there another way to do the parsing if Xpath isn't working? Can you point me toward a guide or some examples? please...


10/10/2012 10:04:08 PM

Accepted Answer

The LINQ API may be applied to:

var doc = new HtmlDocument();
var programmes = doc.DocumentNode.Descendants().Where(d => d.GetAttributeValue("class", "") == "program")

Unfortunately, there wasn't much current information available on this API.

10/15/2012 6:55:42 AM

Popular Answer

With the aid of these few lines, I was able to overcome the difficulty of parsing html code for img css js in the Windows 8 Metro-app that I had written a few weeks before. (for each picture, inHtmlDocument html , linked illustration)

IEnumerable<HtmlNode> imghrefNodes = html.DocumentNode.Descendants().Where(n => n.Name == "img");
foreach (HtmlNode img in imghrefNodes)
   HtmlAttribute att = img.Attributes["src"];
   //in att.Value you can find your img url
   //Here you can do everything what you want with all img links by editing att.Value

You may just substitute for CSS.img with link and src with href similarly for additional nodes.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow