XML DOM Parser Errors (Parser Errors)
- Returns a long integer file position of the error. Previous Page
- Next Page DOM ProcessingInstr
Microsoft's parseError object can be used to retrieve error information from Microsoft's XML parser.
parseError object
A parser error (parser-error) may occur when you try to open an XML document.
Through this parseError object, you can retrieve the error code, the line causing the error, and so on.
Note:The parseError object does not belong to the W3C DOM standard!
File Error (File Error)
In the following code, we will attempt to load a non-existent file and display some error properties:
Read more about well-formed and valid XML in the section. var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.load("ksdjf.xml") 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)
XML Error (XML Error)
In the following code, we will make the parser load a malformed XML document.
(You can access our XML Tutorial 中阅读更多有关形式良好且有效的 XML。)
Read more about well-formed and valid XML in the section. 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) TIY Or
Just view this XML file
Properties of the parseError Object | Attribute |
---|---|
Description | errorCode |
Returns a long integer error code. | reason |
Returns the string containing the reason for the error. | line |
Returns a long integer representing the line number of the error. | linepos |
Returns a long integer representing the line position of the error. | srcText |
Returns the string containing the line that caused the error. | url |
Returns the URL pointing to the loaded document. | filepos |
- Returns a long integer file position of the error. Previous Page
- Next Page DOM ProcessingInstr