Document type definitions (DTDs) define legal building blocks for XML documents. It uses a series of legal elements to define the structure of the document.
A DTD can be declared in an XML document as a line or as an external reference.
DTD - Validation syntax
When you try to open an XML document, the XML parser may generate an error. By accessing the parseError object, you can retrieve the exact code, text, and even line that caused the error.
DTD - Validation example
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.validateOnParse="true"; xmlDoc.load("note_dtd_error.xml"); document.write("
Error Code: "); document.write(xmlDoc.parseError.errorCode); document.write("
Error Reason: "); document.write(xmlDoc.parseError.reason); document.write("
Error Line: "); document.write(xmlDoc.parseError.line);