当前位置: 首页 > 网络学院 > XML相关教程 > XML DOM > DOM ParseError

XML DOM
DOM 节点
DOM 节点列表
DOM 解析
DOM 遍历节点树
DOM Mozilla 和 IE
DOM 获取节点
DOM 设置节点
DOM 删除节点
DOM 更换节点
DOM 建立节点
DOM 添加节点
DOM 克隆节点
DOM 节点类型
DOM Node
DOM NodeList
DOM NamedNodeMap
DOM Document
DOM DocumentType
DOM ProcessingInstr
DOM Element

XML DOM 中的 DOM ParseError


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 540 ::
收藏到网摘: n/a

Microsoft's parseError object can be used to retrieve error information from the Microsoft XML parser.
微软的错误解析(parserError)对象的作用是:从微软的XML解析器中获取错误信息。


The parseError Object
错误解析对象(parserError)

When trying to open an XML document, a parser-error may occur.
当需要打开XML文档时,有时可能会出现解析错误(parser-error)。

With the parseError object, you can retrieve the error code, the error text, the line that caused the error, and more.
通过错误解析(parseError)对象,你可以找回错误代码、错误文本、错误行以及其它更多相关的错误信息。

Note: The parseError object is not a part of the W3C DOM standard!
注意:错误分析对象不是W3C DOM标准的一部分!


File Error
文件错误

In the following code we will try to load a non-existing file, and display some of its error properties:
在下述代码中,我们将加载一个不存在的文件,并显示它的部分错误属性:

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("ksdjf.xml")

document.write("Error code: " + xmlDoc.parseError.errorCode)
document.write("<br />Error reason: " + xmlDoc.parseError.reason)
document.write("<br />Error line: " + xmlDoc.parseError.line)

Try it yourself
自己尝试一下^_^


XML Error
XML错误

In the following code we let the parser load an XML document that is not well-formed.
在下述代码中,我们让解析器加载了一个不规范的(not well-formed)XML文件。

(You can read more about well-formed and valid XML in our XML tutorial)
(如想了解更多关于规范的XML文件信息,请访问我们的XML 教程。)

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("note_error.xml")

document.write("Error code: " + xmlDoc.parseError.errorCode)
document.write("<br />Error reason: " + xmlDoc.parseError.reason)
document.write("<br />Error line: " + xmlDoc.parseError.line)

Try it yourself or just look at the XML file
自己试试看或者看一下XML文件


The parseError Object's Properties
错误解析(parseError)对象的属性

Property
属性
Description
描述
errorCode Returns a long integer error code
返回一个长整数(long integer)形错误代码
reason Returns a string containing the reason for the error
返回包含错误原因的字符串
line Returns a long integer representing the line number for the error
返回一个指明错误行数的长整数(long integer)
linepos Returns a long integer representing the line position for the error
返回一个指明错误位于哪个行位置的一个长整数(long integer)
srcText Returns a string containing the line that caused the error
返回错误所在行的一个字符串
url Returns the URL pointing the loaded document
返回指向已加载文件的URI
filepos Returns a long integer file position of the error
返回指明错误所在文件中的位置的一个长整数(long integer)

评论 (0) All

登陆 | 还没注册?