What is DOM parse error object in XML

This topic describe you about DOM parse error object.
  • 2584

XML DOM Parse Error Object

To retrieve error information from the microsoft XML parser use Microsoft's parseError object.

The parseError Object

The parser-error may occur, when you trying to open an XML document.

you can retrieve the error code, the error text, the line that caused the error, with the parse error object.

Note: The parseError object is not a part of the W3C DOM standard

File Error

xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("unknown.xml");

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

 

Note: In the following code trying to load non-existing file that is why it's gives the error property

XML Error

xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("Sevral_error.xml");

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

 

Note: In the following code the parser load an XML document that is not well-formed. And it give the error


The parseError Object's Properties

 

Property Description
Errorcode It returns the long integer error code
Reason It returns the string value that contain the reason of error
Line It returns the integer that represent no of the error
Linepos It returns the integer that represent the line position for the error
Srctext It returns the string that containg the line which have the error
Url It returns the url of loaded document
Filepos It returns the integers that contain the file position that caused error

 

Further Readings

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.