Latest web development tutorials


XML has the correct syntax is called "good form" in XML.

DTD validation of XML through a "legal" XML.

In the form of well-formed XML documents

"Well Formed" XML document has correct syntax.

Syntax rules described in the previous section:

  • 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
<?xml version="1.0" encoding="ISO-8859-1"?>
<body>Don't forget me this weekend!</body>

Validate XML documents

Legal XML document is a "Well Formed" XML document, which is consistent with the Document Type Definition (DTD) rules:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE note SYSTEM "Note.dtd">
<body>Don't forget me this weekend!</body>

In the example above, DOCTYPE declaration is a reference to an external DTD file. The following paragraphs show the contents of the file.


DTD is intended to define the structure of XML documents. It uses a series of legal elements to define the document structure:

<!DOCTYPE note
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT heading (#PCDATA)>

If you want to learn DTD, please on our home page to find DTD tutorial.

XML Schema

W3C supports an XML-based DTD instead of who it called XML Schema:

<xs:element name="note">

<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>


If you want to learn XML Schema, please our home page to find Schema tutorial.

A generic XML Validator

To help you check the syntax of the XML file, we have created an XML validator, so you can check syntax for any XML document.

See the next chapter.