W3Schools.com (original) (raw)

DTD Tutorial


What is a DTD?

A DTD is a Document Type Definition.

A DTD defines the structure and the legal elements and attributes of an XML document.


Why Use a DTD?

With a DTD, independent groups of people can agree on a standard DTD for interchanging data.

An application can use a DTD to verify that XML data is valid.


An Internal DTD Declaration

If the DTD is declared inside the XML file, it must be wrapped inside the <!DOCTYPE> definition:

XML document with an internal DTD

]>

Tove
Jani
Reminder
Don't forget me this weekend

View XML file »

In the XML file, select "view source" to view the DTD.

The DTD above is interpreted like this:



An External DTD Declaration

If the DTD is declared in an external file, the <!DOCTYPE> definition must contain a reference to the DTD file:

XML document with a reference to an external DTD

Tove Jani Reminder Don't forget me this weekend!

View XML file »

And here is the file "note.dtd", which contains the DTD: