Question: I have a collection of documents that I'm attempting to parse. Like HTML, they are fairly well structured and have a complex syntax/grammar. Also like HTML, many of the documents do not fully adhere to the desired syntax.

My question is, what general strategies do browsers and HTML/XML parsing libraries use when parsing documents that don't strictly follow the right syntax? They seem to deal with misplaced or missing tags well. And I'm sure there are other situations, such as misspelled tags, incorrect attributes, etc. that must be dealt with and not simply ignored.

Answer: 
Keeping it short:

* **in XML** any error in code terminates the parsing process - so called "*Draconian Error Handling*"
* **in XHTML** just as in any XML-based doc - error equals termination
* **in HTML** - the browser tries to render as much, as it can
BEHOLD:

[The HTML5 Parsing Algorithm](http://www.w3.org/TR/html5/parsing.html)