Introduction to XML | Defining XML Structures with DTD | DOCTYPE Declaration

Use a document type declaration (DOCTYPE) to associate an XML document with a DTD. The DTD can be written inside the document or stored externally.

The following form writes a DTD as an internal subset:

<!DOCTYPE root-element [
    <!-- internal subset -->
]>

To associate an external DTD and optionally include an internal subset, use SYSTEM:

<!DOCTYPE root-element SYSTEM "URI" [
    <!-- internal subset -->
]>

When no internal subset is needed, the declaration is simpler:

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE inventory SYSTEM "http://www.devkuma.com/sample.dtd">

<inventory>
    <product>
        <name>Bicycle</name>
        <quantity>20</quantity>
    </product>
</inventory>

For a publicly available DTD, use PUBLIC with a public identifier and URI:

<!DOCTYPE root-element PUBLIC "public-identifier" "URI">

XHTML is an example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">