Use of the document type declaration.

Q12. What is the use of the document type declaration? How is it different from DTD?

Ans. The document type declaration is used to specify a Document Type Definition (DTD) document that contains the grammar rules or guidelines for a particular class or section of the XML document. The document type declaration begins with the! DOCTYPE declaration. The following code snippet shows the use of document type declaration:

<!DOCTYPE Animals SYSTEM = “Anim.dtd”>

On the other hand, DTD refers to the document that defines the structure and rules of an XML document. The following code snippet shows an example of a DTD document:

<?xml version=”1.0”?>

<!DOCTYPE email [

<!ELEMENT email (to, from, heading, body)>



<!ELEMENT heading (#PCDATA)>



Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: