Click here to Skip to main content
13,252,362 members (54,906 online)
Click here to Skip to main content
Add your own
alternative version


152 bookmarked
Posted 21 Mar 2004


, 30 Mar 2004
Rate this:
Please Sign up or sign in to vote.
A non-well-formed HTML parser for .NET


This library produces a domain tree of a given HTML document, allowing the developer to navigate and change the document in an methodical way. In addition to the basic HTML production, this library can also be used to produce XHTML documents, as it includes an HTML 4 entity encoder. Included in this release is a demonstration application in VB.NET showing how to use the library. I hope that it is all fairly self-explanatory.


This library was written to avoid having to convert a document into XML prior to reading, whilst preserving the distinct HTML qualities. This gets round some deployment issues I had with different platforms.

Using the code

The simplest way to use the code is to add it into your solution as a C# class library. There are no third-party dependencies so it is just a matter of adding the source files in. Alternatively, you can build the DLL and add it as a reference.

Points of Interest

The XHTML production is fairly basic - there is no built-in DTD checking. So far, I have had no problems in the generation, but I'm keen on getting that sorted.


  • 1.4
  • 1.3
    • Bugfix: <!DOCTYPE...> and <!...> now treated as comments
    • Bugfix: Malformed or incomplete attribute values causing infinite loop fixed
  • 1.2
    • Bugfix: <tag/> now handled properly
    • Bugfix: Parse errors of scripts
    • Bugfix: Parse errors of styles
    • HTML 4 entity encoding
    • DOM tree navigation
    • Basic node searching
    • HTML production
    • XHTML production (as per
    • Added some component model stuff & comments
    • Hid the parser
  • 1.1
    • Initial release


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Member 987427
United Kingdom United Kingdom
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionWhitespace between text and anchor Pin
Mike11424-Oct-12 15:59
memberMike11424-Oct-12 15:59 
BugBug fix for pages with different encoding Pin
Member 846475913-Dec-11 6:40
memberMember 846475913-Dec-11 6:40 
BugBug fix in returning multi empty spaces between words Pin
Member 846475912-Dec-11 5:31
memberMember 846475912-Dec-11 5:31 
BugError : Input string was not in a correct format. Pin
Member 846475912-Dec-11 1:51
memberMember 846475912-Dec-11 1:51 
GeneralRe: Error : Input string was not in a correct format. Pin
Konakov Sergey25-Feb-16 11:39
memberKonakov Sergey25-Feb-16 11:39 
Questionthank you Pin
Member 84647596-Dec-11 7:09
memberMember 84647596-Dec-11 7:09 
GeneralMy vote of 5 Pin
jp73125-Nov-10 1:45
memberjp73125-Nov-10 1:45 
NewsWorks very good for Google! Pin
jp73125-Nov-10 1:45
memberjp73125-Nov-10 1:45 
GeneralDoes not remove whitespaces Pin
evald8018-Jan-10 1:25
memberevald8018-Jan-10 1:25 
GeneralGood man good Pin
niks0412-Jan-10 19:31
memberniks0412-Jan-10 19:31 
QuestionCan I get MIL HTML parser Algorithm. Pin
Hasibul Haque26-May-09 10:21
memberHasibul Haque26-May-09 10:21 
Generalcongratulations Pin
vukovicg13-May-09 5:03
membervukovicg13-May-09 5:03 
GeneralSimply amazing! Pin
the Asocial Ape13-May-09 4:57
memberthe Asocial Ape13-May-09 4:57 
GeneralLowercased href Pin
exxellence12-Nov-08 2:04
memberexxellence12-Nov-08 2:04 
Generalfeature missing Pin
zeltera17-Aug-08 5:34
memberzeltera17-Aug-08 5:34 
GeneralRe: feature missing Pin
smitsc7-Oct-08 9:11
membersmitsc7-Oct-08 9:11 
GeneralDOCTYPE breaks the parser Pin
benblo14-May-08 6:18
memberbenblo14-May-08 6:18 
QuestionIs it a bug? Pin
huyhk27-Feb-08 21:57
memberhuyhk27-Feb-08 21:57 
GeneralRe: Is it a bug? Pin
Natural Cause26-Mar-08 23:34
memberNatural Cause26-Mar-08 23:34 
GeneralRe: Is it a bug? Pin
NoodleNoggin981-Jul-09 11:03
memberNoodleNoggin981-Jul-09 11:03 
GeneralRe: Is it a bug? [modified] Pin
Member 458246616-Jul-09 13:21
memberMember 458246616-Jul-09 13:21 
GeneralRe: Is it a bug? Pin
Jeremy Falcon8-Jul-09 5:50
memberJeremy Falcon8-Jul-09 5:50 
Natural Cause wrote:
You don't wrap any of the values in double quotes

Actually that's perfectly valid HTML. It's invalid in XHTML, and although I prefer quoting, it's still valid.

Jeremy Falcon[^]

GeneralSuggestions for new interface methods Pin
Berend Engelbrecht26-Feb-08 10:10
memberBerend Engelbrecht26-Feb-08 10:10 
GeneralFound a bug Pin
stavinski14-Jan-08 11:09
memberstavinski14-Jan-08 11:09 
AnswerRe: Found a bug - me too, and the solution Pin
Berend Engelbrecht25-Feb-08 22:04
memberBerend Engelbrecht25-Feb-08 22:04 
QuestionHTML marked Pin
maingaosuong25-Sep-07 17:19
membermaingaosuong25-Sep-07 17:19 
Generalregarding extracting tags Pin
rama jayapal29-Mar-07 4:49
memberrama jayapal29-Mar-07 4:49 
GeneralRe: regarding extracting tags Pin
James S.F. Hsieh29-Mar-07 23:09
memberJames S.F. Hsieh29-Mar-07 23:09 
GeneralYou can try it. :) Pin
James S.F. Hsieh27-Mar-07 23:36
memberJames S.F. Hsieh27-Mar-07 23:36 
Generalmisses some IMG nodes Pin
encapsul10-Mar-07 8:53
memberencapsul10-Mar-07 8:53 
QuestionStrings instead of Streams? Pin
Yuvi Panda26-Sep-06 7:15
memberYuvi Panda26-Sep-06 7:15 
AnswerRe: Strings instead of Streams? Pin
Lennard Fonteijn1-Dec-06 14:16
memberLennard Fonteijn1-Dec-06 14:16 
GeneralRe: Strings instead of Streams? Pin
Yuvi Panda1-Dec-06 15:32
memberYuvi Panda1-Dec-06 15:32 
GeneralMove the project elsewhere Pin
KCorax221-Aug-06 10:55
memberKCorax221-Aug-06 10:55 
QuestionCan not fix some error of HTML code . Pin
dinhdv200124-Jul-06 15:36
memberdinhdv200124-Jul-06 15:36 
GeneralSpaces Removed Between Tags Pin
Michael Babb6-Jun-06 10:50
memberMichael Babb6-Jun-06 10:50 
GeneralRe: Spaces Removed Between Tags Pin
Member 577449914-Dec-08 6:40
memberMember 577449914-Dec-08 6:40 
Generala suggestion Pin
XiongHarry14-Apr-06 23:09
memberXiongHarry14-Apr-06 23:09 
GeneralMinor error in parsing &lt;!DOCTYPE ..> Pin
jmas810916-Mar-06 4:27
memberjmas810916-Mar-06 4:27 
GeneralThis rocks. Pin
rhino-x29-Jan-06 12:43
memberrhino-x29-Jan-06 12:43 
GeneralGood job! Pin
Bobga4-Nov-05 12:43
memberBobga4-Nov-05 12:43 
Generalbug with filterindex in vb demo Pin
mgambrell17-Oct-05 14:37
membermgambrell17-Oct-05 14:37 
GeneralI found some bugs. Pin
Nomad Libra7-Sep-05 9:15
sussNomad Libra7-Sep-05 9:15 
GeneralAttribute with blank name and null value Pin
vnguyen91121-Jul-05 13:25
membervnguyen91121-Jul-05 13:25 
Generaleats special characters Pin
Steven A. Lowe21-Mar-05 8:45
memberSteven A. Lowe21-Mar-05 8:45 
GeneralRe: eats special characters Pin
Steven A. Lowe21-Mar-05 10:38
memberSteven A. Lowe21-Mar-05 10:38 
Generalmistreats SSI and server scripts Pin
Steven A. Lowe15-Mar-05 12:21
memberSteven A. Lowe15-Mar-05 12:21 
GeneralRe: mistreats SSI and server scripts Pin
Steven A. Lowe17-Mar-05 6:20
memberSteven A. Lowe17-Mar-05 6:20 
GeneralBug in DOCTYPE Pin
arca_21-Feb-05 9:41
memberarca_21-Feb-05 9:41 
GeneralError when parsing &lt;a href=...&gt; on Pin
marshall-cline15-May-04 10:11
membermarshall-cline15-May-04 10:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 31 Mar 2004
Article Copyright 2004 by Member 987427
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid