May 27, 2021 XML DOM
Microsoft's parseError object can be used to get the error message back from Microsoft's XML analyzer.
To see how Firefox handles parser errors, see the next page of this tutorial.
A parser-error can occur when you try to open an XML document.
With this parseError object, you can get back error codes, error text, lines that cause errors, and so on.
Note: The parseError object does not belong to the W3C DOM standard!
In the following code, we try to load a file that doesn't exist and display some error properties:
In the following code, we'll have the parser load a poorly formed XML document.
(You can read more about good and effective XML in our XML tutorial.) )
View XML files: note_error.xml
属性 | 描述 |
---|---|
errorCode | 返回一个长整数错误代码。 |
reason | 返回一个字符串,包含错误的原因。 |
line | 返回一个长整数,代表错误的行号。 |
linepos | 返回一个长整数,代表错误的行位置。 |
srcText | 返回一个字符串,包含引起错误的行。 |
url | 返回指向被加载文档的 URL。 |
filepos | 返回错误的一个长整型文件位置。 |