Example 1     <<      >>       intro       contents     

An XML document is valid if it has an associated document type declaration and if the document complies with the constraints expressed in it. The document type declaration must appear before the first element in the document. The name following the word DOCTYPE in the document type declaration must match the name of root element.

  DTD   HOME     

A document can contain only the root element tutorial which can contain some text. :

               <!ELEMENT tutorial (#PCDATA)>
               
            


  Valid documents   HOME     

A valid document containing some text.:

               <!DOCTYPE tutorial SYSTEM "tutorial.dtd">

               <tutorial>This is an XML document</tutorial>
               
            

This document is also valid.:

               <!DOCTYPE tutorial SYSTEM "tutorial.dtd">

               <tutorial/>
               
            

  Documents with errors   HOME     

Root element does not conform to the given DTD.:

               <!DOCTYPE tutorial SYSTEM "tutorial.dtd">

               <text>This is an XML document</text>