XML学习札记--Parser Errors

The parseError Object
当您尝试打开一个XML文档的时候,XML解析器可能会发现文档中存在某些错误,通过访问parseError对象,将返回一些值,如error code,error text,error line等
Example
使用如下代码,load非现成的xml文档或者load一个现成的存在xml语法错误的xml文档,按照 实际情况将会有不同的结果.

<script language="JavaScript" type="text/JavaScript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("note_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)
document.write("<br>Error linePos: ")
document.write(xmlDoc.parseError.linePos)
document.write("<br>Error srcText: ")
document.write(xmlDoc.parseError.srcText)
document.write("<br>Error url: ")
document.write(xmlDoc.parseError.url)
document.write("<br>Error filePos: ")
document.write(xmlDoc.parseError.filePos)
</script>


The parseError Properties
PropertyDescription
errorCodeReturns a long integer error code
reasonReturns a string explaining the reason for the error
lineReturns a long integer representing the line number for the error
linePosReturns a long integer representing the line position for the error
srcTextReturns a string containing the line that caused the error
urlReturns the url pointing the loaded document
filePosReturns a long integer file position of the error
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值