Htmlagilitypack And Windows 8 Winrt
I'm trying to build a metro app for windows 8. In this app i'm trying to parse data from a website. For that i'm using HtmlAgilityPack 1.4.6. BUT i'm getting really confused about
Solution 1:
You can use the LINQ API:
var doc = newHtmlDocument();
doc.LoadHtml(contents);
var programmes = doc.DocumentNode.Descendants().Where(d => d.GetAttributeValue("class", "") == "program")
Unfortunately, I couldn't find much up-to-date information on this API.
Solution 2:
I was created few weeks ago my own algorithm to save web page and I also solved problem for parsing html code for img css js in windows 8 metro-app with help of these few lines:(for all images, in HtmlDocument html
, links example)
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
}
For css you can just replace img
with link
and src
with href
. For other nodes the same way.
Post a Comment for "Htmlagilitypack And Windows 8 Winrt"