spacer
Yehuda Shiran February 20, 2002
Printing A Parsing Error
Tips: February 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management
When loading XML files, you must keep error handling in place. Otherwise, debugging the XML, DTD, and XSL files is going to be very time consuming. The following script reads 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);
  }

People who read this tip also read these tips:

Look for similar tips by subject:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering MySQL Databases on the Web Using PHP · Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
So what is an Oracle Nested Table? · E-Discovery Architectures 101 · eBay Embraces Big Sellers, Cyber Monday Trends