Share on Google+Share on Google+

XML Validation

XML validated against a DTD or a Schema is a Valid XML.

XML Validation


XML with correct syntax is Well Formed XML.

XML validated against a DTD or a Schema  is a Valid XML.

Well Formed XML Documents

A "Well Formed" XML document has correct XML syntax.

A "Well Formed" XML document is a document that conforms to the XML syntax rules that were described in the previous chapters:

  • XML documents must have a root element
  • XML elements must have a closing tag
  • XML tags are case sensitive
  • XML elements must be properly nested
  • XML attribute values must always be quoted


<?xml version="1.0" encoding="ISO-8859-1"?>
<Body>Be ready for a cruise...i will catch u  tonight</Body>

Valid XML Documents:

A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD) or a XML Schema .

The following xml document is validated against a DTD , notice the highlighted text.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE e-mail SYSTEM "InternalE-mail.dtd">
<Body>Be ready for a cruise...i will catch u  tonight</Body>


A DTD defines the legal elements of an XML document. The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements.

XML Schema 

XML Schema is an XML based alternative to DTD .W3C supports an alternative to DTD called XML Schema.



Posted on: May 24, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: XML Validation   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image