DTD verify


Using Internet Explorer, you can validate your XML against a DTD.


Validation via XML parser

When you attempt to open an XML document, the XML parser may generate errors. By accessing the parseError object, you can retrieve the exact code, text, and even the line where the error occurred.

Note:The load() method is used for files, while the loadXML() method is used for strings.

Example

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);

Try it Yourself »

View XML file


disable validation

By setting the XML parser's validateOnParse to "false", you can turn off validation.

Example

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);

Try it Yourself »


Universal XML validator

To help you validate XML files, we created thisLinks, so that you can validate any XML file.


parseError object

You can in ourXML DOM TutorialRead more about the parseError object in.

other extensions