DTD 校验

Internet Explorer 5.0 can validate your XML against a DTD.
IE5.0可以通过DTD检验你的XML。


Validating with the XML Parser
用XML剖析器确认

If you try to open an XML document, the XML Parser might generate an error. By accessing the parseError object, the exact error code, the error text, and even the line that caused the error can be retrieved:
如果你想打开一个XML文件,那XML剖析器会产生错误。通过访问分析错误目标,精确的错误代码、错误文本以及引起错误的线路都能找到。

Note: The load( ) method is used for files, while the loadXML( ) method is used for strings.
注意:The load( ) method是用于文件的,而the loadXML( ) method是用于字符串的。

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)

你可以自己尝试一下 或 查看这个XML文件


Turning Validation off
关闭确认

Validation can be turned off by setting the XML parser's validateOnParse="false".
确认可以通过XML解析器的validateOnParse="false"来关闭。

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)

自己尝试一下吧


A general XML Validator
XML通用的确认方法

To help you validate your xml files, we have created this link so that you can Validate any XML file.
如想确认你的XML文件,我们创建了一个可以快速访问Validate any XML file(确认XML文件)的链接


The parseError Object
分析错误对象(Object)

You can read more about the parseError object in our XML DOM tutorial.
如想了解更多关于parseError 对象的情况,请访问我们DOM tutorial (DOM教程)。

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值