Labels

Thursday, April 30, 2009

Well Formed vs Valid XML Document - Quick Reference

An XML document has two correctness levels:

 

  • Well-formed. A well-formed document conforms to the XML syntax rules; e.g. if a start-tag (< >) appears without a corresponding end-tag (</>), it is not well-formed. A document not well-formed is not in XML; a conforming parser is disallowed from processing it.

 

  • Valid. A valid document additionally conforms to semantic rules, either user-defined or in an XML schema, especially DTD; e.g. if a document contains an undefined element, then it is not valid; a validating parser is disallowed from processing it.

 

Below is not well-formed.

 

<!-- WRONG! NOT WELL-FORMED XML! -->
<title>Book on Logic<author>Aristotle</title></author>
 
<!-- Correct: well-formed XML fragment. -->
<title>Book on Logic</title> <author>Aristotle</author>

 

 

Thanks & Regards,

Arun Manglick || Senior Tech Lead

 

 

No comments:

Post a Comment