XML Validation
XML with correct syntax is called "well-formed" XML.
XML validated against a DTD is "valid" XML.
Well-Formed XML Documents
A "well-formed" XML document has correct syntax.
The syntax rules described in the previous chapters:
- An XML document must have a root element
- XML elements must all 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):
In the example above, the DOCTYPE declaration is a reference to an external DTD file. The following section shows the content of this file.
XML DTD
The purpose of a DTD is to define the structure of an XML document. It uses a series of legal elements to define the document structure:
]>
If you want to learn DTD, please refer to ourHomeDTD tutorial.
XML Schema
The W3C supports an XML-based alternative to DTD, named XML Schema:
If you want to learn about XML Schema, please refer to ourHomeSchema tutorial.
A Universal XML Validator
To help you check the syntax of XML files, we have created an XML validator so that you can perform syntax checks on any XML file.
See the next chapter.