DTD 验证

Internet Explorer 5.0 可根据某个 DTD 来验证您的 XML。

通过 XML 解析器进行验证

当您试图打开某个 XML 文档时,XML 解析器有可能会产生错误。通过访问 parseError 对象,就可以取回引起错误的确切代码、文本甚至所在的行。

注释:load( ) ханнунна ханна файл, а loadXML( ) ханна ханна ханна ханна.

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 or Just take a look at this XML file.

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)

Try it Yourself

General XML Validator

To help you validate XML files, we have created this link so you can validate any XML file.

parseError object

You can find our in ourXML DOM Tarinai》Read more about parseError object information.