DTD validation
- Previous Page DTD Entity
- Next Page DTD Example
Internet Explorer 5.0 can validate your XML based on a DTD.
Validation through XML parser
When you try to open an XML document, the XML parser may produce errors. By accessing the parseError object, you can retrieve the exact code, text, and even the line number that caused the error.
Note:The load() method is used for files, while the loadXML() method is used for strings.
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.validateOnParse="true" xmlDoc.load("note_dtd_error.xml") document.write("<br>Error Code: ") document.write(xmlDoc.parseError.errorCode) document.write("<br>Error Reason: ") document.write(xmlDoc.parseError.reason) document.write("<br>Error Line: ") document.write(xmlDoc.parseError.line)
Turn Off Validation
By setting the validateOnParse of the XML parser to "false", you can turn off validation.
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.validateOnParse="false" xmlDoc.load("note_dtd_error.xml") document.write("<br>Error Code: ") document.write(xmlDoc.parseError.errorCode) document.write("<br>Error Reason: ") document.write(xmlDoc.parseError.reason) document.write("<br>Error Line: ") document.write(xmlDoc.parseError.line)
General XML Validator
To help you validate XML files, we have created this link so that you can validate any XML file.
parseError Object
You can find more information about the parseError object in our 'XML DOM TutorialRead more about the parseError object in section '》'.
- Previous Page DTD Entity
- Next Page DTD Example