HAP
Html Agility Pack

Download Count:
3  ,  9 7 9  ,  9 0 9
EASY TO
USE
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
// From File
var doc = new HtmlDocument(); 
doc.Load(filePath); 
// From String var doc = new HtmlDocument(); 
doc.LoadHtml(html); 
// From Web var url = "http://html-agility-pack.net/"; 
var web = new HtmlWeb(); 
var doc = web.Load(url);
EASY TO
CUSTOMIZE
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
// With XPath	
var value = doc.DocumentNode
	.SelectNodes("//td/input")
	.First()
	.Attributes["value"].Value;
	
// With LINQ	
var nodes = doc.DocumentNode.Descendants("input")
	.Select(y => y.Descendants()
	.Where(x => x.Attributes["class"].Value == "box"))
	.ToList();

 By Millions!

Discover why thousands of developers around the world use Html Agility Pack

FREE & Open Source

Want to contribute? Access to the full source and help us by providing a pull request.

GitHub

Stack Overflow Support

Have a question? Ask questions and find answers from over 2500 questions.

Stack Overflow

Tutorials & Examples

Need help to getting started? Find answers you need through tutorials and online examples.

Tutorials

Issue Tracker

Found a bug? Have suggestion? Report it and get support from our professional team.

Issues

Getting Started - HTML Agility Pack

HTML Parser

Load and parse HTML

Html Parser Tutorials
C#HTML Parser Examples
// From File
var doc = new HtmlDocument();
doc.Load(filePath);

// From String
var doc = new HtmlDocument();
doc.LoadHtml(html);

// From Web
var url = "http://html-agility-pack.net/";
var web = new HtmlWeb();
var doc = web.Load(url);

HTML Selectors

Select HtmlNode, Element, and Attributes:

HTML Selectors Tutorials
C#HTML Selectors Examples
// With XPath	
var value = doc.DocumentNode
	.SelectNodes("//td/input")
	.First()
	.Attributes["value"].Value;
	
// With LINQ	
var nodes = doc.DocumentNode.Descendants("input")
	.Select(y => y.Descendants()
	.Where(x => x.Attributes["class"].Value == "box"))
	.ToList();

HTML Manipulation

Manipulate HtmlNode, Element, and Attributes:

HTML Manipulation Tutorials
C#HTML Manipulation Examples
var doc = new HtmlDocument();
doc.LoadHtml(html);

// InnerHtml	
var innerHtml = doc.DocumentNode.InnerHtml;

// InnerText	
var innerText = doc.DocumentNode.InnerText;

HTML Traversing

Traverse HtmlNode, Element, and Attributes:

HTML Traversing Tutorials
C#HTML Traversing Examples
var doc = new HtmlDocument();
htmlDoc.LoadHtml(html);

// Descendants	
var nodes = doc.DocumentNode.Descendants("input");





Stay in Touch

Sign up for our mailing list to get latest updates