XML with correct syntax is Well Formed XML.
XML validated against a DTD is Valid XML.
A "Well Formed" XML document is a document that conforms to the XML
syntax rules that were described in the previous chapters:
<?xml version="1.0"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> |
A "Valid" XML document is a "Well Formed" XML document, which also conforms
to the rules of a Document Type Definition (DTD):
<?xml version="1.0"?> <!DOCTYPE note SYSTEM "InternalNote.dtd"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> |
The purpose of a DTD is to define the legal building blocks of an XML
document. It defines the document structure with a list of legal elements.
You can read more about DTD, and how to validate your XML documents in
W3Schools'
DTD School.
W3C supports an alternative to DTD called XML Schema. You can read more
about XML Schema in W3Schools' Schema School.
The W3C XML specification states that a program should not continue to process an XML document if it finds a validation error. The reason is that XML software should be easy to write, and that all XML documents should be compatible.
With HTML it was possible to create documents with lots of errors (like when you forget an end tag). One of the main reasons that HTML browsers are so big and incompatible, is that they have their own ways to figure out what a document should look like when they encounter an HTML error.
With XML this should not be possible.