Q
Problem solve Get help with specific problems with your technologies, process and projects.

Is there a DTD for HTML?

Is there a DTD for HTML? If so, can an XML parser parse HTML documents with it? I'm looking for a simple way to parse HTML documents the same as I can parse XML documents with JAXP.
HTML is an SGML application and although it has a DTD (https://www.w3.org/TR/html401/), SGML DTDs are different from XML DTDs.

An SGML system can work with all XML DTDs (in theory at least) but XML systems cannot work with all SGML DTDs.

The big problem is that HTML parsers need to infer the structure of the document when tags (such as </p>) are missing. This is hard and not all tools give you the same result.

There are two tools worth looking at for getting your HTML into shape to be parseable as XML: Dave Ragget's HTML Tidy and James Clark's SGML to XML conversion.

Dig Deeper on Topics Archive

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchSoftwareQuality

SearchAWS

SearchCloudComputing

TheServerSide.com

Close