This is the part that I wanted to lay emphasis onto, as follows:
Linq to Objects approach
public string GetInnerTextWithLinq() { var document = new HtmlDocument(); document.Load(new FileStream("test.html", FileMode.Open)); var node = document.DocumentNode.Descendants("div").Where( d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("required")).SingleOrDefault(); return node.InnerText; }
Check the link for more details and feel free to add your comments
Crawling a web sites with HtmlAgilityPack
No comments:
Post a Comment