Web based School

XML Validator

The cool thing about XML is that it can be validated for syntax error using DTD or Schema. In this guide we will learn what is a valid xml, what are the rules and the ways to check for a valid XML document.
Well Formed XML document
An XML document with correct syntax is known as valid XML document. Lets see few important rules to check for syntax errors.

Rules:
1. All XML documents must have a root element.
2. XML is a case sensitive language so you should be careful with the case while opening and closing tags.
3. All XML tags must have a closing tag.
4. XML attribute name should not be quoted while its value must be quoted.


For more rules check this guide: XML Syntax

Ways to check a valid XML document
There are two document type definitions that can used with XML document to check whether the XML document is valid.
1. XML DTD (Document Type Definition)
2. XML Schema – An XML-based alternative to the Document Type Definition


1. XML DTD
DTD defines the structure of XML document that can be validated against the XML document to check for the syntax errors. XML DTD defines the structure by mentioning the XML elements in such a way so that the complete structure of XML document can be understood. The DTD file has .dtd extension.

2. XML Schema
The Schema does the same thing that a DTD can do. It also defines the structure of the XML document but unlike DTD it is an XML file, in addition to that Schema supports data types and namespaces.

Previous Next