XML Validation
XML with correct grammar is referred to as "well-formed" XML.
XML validated by DTD is considered "valid" XML.
Well-formed XML Documents
A "well-formed" XML document has correct grammar.
The grammar rules described in the previous chapters:
- An XML document 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 be quoted
Validating XML Documents
A valid XML document is a "well-formed" XML document that also conforms to the rules of a Document Type Definition (DTD): <!DOCTYPE note SYSTEM "Note.dtd">
In the above example, the DOCTYPE declaration refers to an external DTD file. The following paragraphs show the contents of this file.
XML DTD
The purpose of DTD is to define the structure of an XML document. It uses a set of legal elements to define the document structure:
If you want to learn about DTD, please find the DTD tutorial on our homepage.
XML Schema
The W3C supports an XML-based alternative to DTD, called XML Schema:
If you want to learn about XML Schema, please find the Schema tutorial on our homepage.
A Generic XML Validator
To help you check the syntax of XML files, we have created an XML validator for you to check the syntax of any XML file.
See the next chapter.