Skip to content

Instantly share code, notes, and snippets.

@lmatt-bit
Created April 3, 2013 15:27
Show Gist options
  • Select an option

  • Save lmatt-bit/5302231 to your computer and use it in GitHub Desktop.

Select an option

Save lmatt-bit/5302231 to your computer and use it in GitHub Desktop.
Html Agility Pack Usage Example
using HtmlAgilityPack;
//Download http://somapage
WebClient wc = new WebClient();
var page = wc.DownloadString("http://somepage");
//use Html Agility Pack to load Html
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(page);
//Find Element by id
var TargetNode = doc.GetElementbyId("SomeId");
//Find nodes by some condition
var TargetNodeSubList = TargetNode.SelectNodes("//div/p[@class='content']");
//Find single node by some condition
var TargetNodeSubNode = TargetNode.SelectSingleNode("//a[@title='nextpage']");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment