Click here to Skip to main content
15,886,518 members
Articles / Programming Languages / Visual Basic
Article

MIL HTML Parser

Rate me:
Please Sign up or sign in to vote.
4.79/5 (77 votes)
30 Mar 20041 min read 393.1K   7.8K   154   74
A non-well-formed HTML parser for .NET

Introduction

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.

Background

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.

History

  • 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 http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd)
    • Added some component model stuff & comments
    • Hid the parser
  • 1.1
    • Initial release

License

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


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionCan I get MIL HTML parser Algorithm. Pin
Hasibul Haque26-May-09 9:21
professionalHasibul Haque26-May-09 9:21 
Generalcongratulations Pin
vukovicg13-May-09 4:03
vukovicg13-May-09 4:03 
GeneralSimply amazing! Pin
the Asocial Ape13-May-09 3:57
the Asocial Ape13-May-09 3:57 
GeneralLowercased href Pin
exxellence12-Nov-08 1:04
exxellence12-Nov-08 1:04 
Generalfeature missing Pin
zeltera17-Aug-08 4:34
zeltera17-Aug-08 4:34 
GeneralRe: feature missing Pin
smitsc7-Oct-08 8:11
smitsc7-Oct-08 8:11 
GeneralDOCTYPE breaks the parser Pin
benblo14-May-08 5:18
benblo14-May-08 5:18 
QuestionIs it a bug? Pin
huyhk27-Feb-08 20:57
huyhk27-Feb-08 20:57 
GeneralRe: Is it a bug? Pin
Natural Cause26-Mar-08 22:34
Natural Cause26-Mar-08 22:34 
GeneralRe: Is it a bug? Pin
NoodleNoggin981-Jul-09 10:03
NoodleNoggin981-Jul-09 10:03 
GeneralRe: Is it a bug? [modified] Pin
Mr 458246616-Jul-09 12:21
Mr 458246616-Jul-09 12:21 
GeneralRe: Is it a bug? Pin
Jeremy Falcon8-Jul-09 4:50
professionalJeremy Falcon8-Jul-09 4:50 
GeneralSuggestions for new interface methods Pin
Berend Engelbrecht26-Feb-08 9:10
Berend Engelbrecht26-Feb-08 9:10 
GeneralFound a bug Pin
stavinski14-Jan-08 10:09
stavinski14-Jan-08 10:09 
AnswerRe: Found a bug - me too, and the solution Pin
Berend Engelbrecht25-Feb-08 21:04
Berend Engelbrecht25-Feb-08 21:04 
QuestionHTML marked Pin
maingaosuong25-Sep-07 16:19
maingaosuong25-Sep-07 16:19 
Generalregarding extracting tags Pin
rama jayapal29-Mar-07 3:49
rama jayapal29-Mar-07 3:49 
GeneralRe: regarding extracting tags Pin
James S.F. Hsieh29-Mar-07 22:09
James S.F. Hsieh29-Mar-07 22:09 
GeneralYou can try it. :) Pin
James S.F. Hsieh27-Mar-07 22:36
James S.F. Hsieh27-Mar-07 22:36 
Generalmisses some IMG nodes Pin
encapsul10-Mar-07 7:53
encapsul10-Mar-07 7:53 
QuestionStrings instead of Streams? Pin
Yuvi Panda26-Sep-06 6:15
Yuvi Panda26-Sep-06 6:15 
AnswerRe: Strings instead of Streams? Pin
Lennard Fonteijn1-Dec-06 13:16
Lennard Fonteijn1-Dec-06 13:16 
GeneralRe: Strings instead of Streams? Pin
Yuvi Panda1-Dec-06 14:32
Yuvi Panda1-Dec-06 14:32 
GeneralMove the project elsewhere Pin
KCorax221-Aug-06 9:55
KCorax221-Aug-06 9:55 
QuestionCan not fix some error of HTML code . Pin
dinhdv200124-Jul-06 14:36
dinhdv200124-Jul-06 14:36 

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.