XML DTD defines the structure and elements of an XML document. An XML schema also defines the structure of an XML document and specifies elements, attributes, data types. The example XML document uses a DTD to validate that the elements <to>, <from>, <heading>, and <body> are in the correct order within the <note> tags.