My teacher told us that an XML document which will be treated by a JavaScript program must be ruled by a Document Type Definition. He didn't explain why, and I'm wondering about it.
Indeed, DTD are not required : these constraints are just recommended for a lot of reasons. But why should we use DTD if our JavaScript program will treat the XML document ?
Using DTD (or better XSD schema) makes sure the XML document is a valid document. This way your JavaScript code will be much simpler and will not have to take care about cases if some element is missing or contains unexpected data type.
For example, if your XML document contains
<birthdate>last-year</birthdate>
, your JavaScript should know what to do with this value. It is much simpler to apply validation (DTD or XSD) and make sure the document is valid.