C# html Parser

C# html Parser

  If you came here by searching for C#.net or VB.net html parser, your search ends here.

While developing screen scrapping with C#.net, I came across very rich open source HtmlParser. Who is capable of parsing entire html document.

Here is a link to download and parse the required fields in html  
http://www.codeplex.com/htmlagilitypack.

It is very similar to librarys provided by .net to parse or iterate XMLDocuments.

code snippet:

It will give you list of  all nodes of type Input.  Here str is your actual HTML string that you received in HttpWebResponse object

 HtmlAgilityPack.HtmlDocument hd = new HtmlAgilityPack.HtmlDocument();

hd.LoadHtml(str);

HtmlNodeCollection hc = hd.DocumentNode.SelectNodes("//input");


You can use Xpath query to iterate nodes and ChildNodes.

Satalaj

Tags:

C# HtmlTextWriter ExampleC# html ParserBasic HTML5 TagsAsp.net How to display HTML contentsRegularExpression remove html tagsOnline html editor online JavaScript editorC# foreach loopAsp.net Create Html ControlsHTML5 TutorialHTML5 With DataBaseASP.net HTML5 Generate Article Tag

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.