February 20, 2002 - Printing A Parsing Error
February 20, 2002 Printing A Parsing Error Tips: February 2002
Yehuda Shiran, Ph.D.
|
mydvd7.xml
, prints a relevant error message if the parsing was not successful, and prints the DOM tree otherwise:
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
var namedNodeMap;
xmlDoc.async = false;
xmlDoc.load("mydvd7.xml");
if (xmlDoc.parseError.errorCode != 0) {
alert("errorCode: " + xmlDoc.parseError.errorCode + "\n" +
"filepos: " + xmlDoc.parseError.filepos + "\n" +
"line: " + xmlDoc.parseError.line + "\n" +
"linepos: " + xmlDoc.parseError.linepos + "\n" +
"reason: " + xmlDoc.parseError.reason + "\n" +
"srcText: " + xmlDoc.parseError.srcText + "\n" +
"url: " + xmlDoc.parseError.url);
} else {
alert(xmlDoc.documentElement.xml);
}