XML Validation

XML with correct syntax is Well Formed XML. XML validated against a DTD is Valid XML.

  • "Well Formed" XML documents.

    A "Well Formed" XML document has correct XML syntax. A "Well Formed" XML document is a document that conforms to the XML syntax rules that were described in the previous chapters:

    Internal DTD

    This is an XML document with a Document Type Definition:
    <?xml version="1.0"?>
    <!DOCTYPE note [
      <!ELEMENT note    (to,from,heading,body)>
      <!ELEMENT to      (#PCDATA)>
      <!ELEMENT from    (#PCDATA)>
      <!ELEMENT heading (#PCDATA)>
      <!ELEMENT body    (#PCDATA)>
    ]>
    <note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
    </note> 


  • "Valid" XML documents

    A "Valid" XML document also conforms to a DTD. A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD):

    External DTD

    This is the same XML document with an external DTD: 
    <?xml version="1.0"?>
    <!DOCTYPE note SYSTEM "note.dtd">
    <note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body>Don't forget me this weekend!</body>
    </note> 

    Top