PROPERTY:  ParseError::srcText

This property is a Microsoft extension to the W3C DOM.


The srcText property is read-only and returns the full text of the line containing the error as a string. It returns an empty string if the error is because of XML that is not well-formed, and cannot be pinned down to a specific line.

In the following example the file 'currencies.xml' is loaded which includes an error: the slash character (/) is missing from the closing tag of the fourth 'currency' element. If a parse error occurs, as it does in this case, an alert displays the number of the line where it occurs, and the complete text of that line.

Where no parse error occurs, the errorCode property returns 0.

   <currency>CHF Swiss Francs</currency>
   <currency>DEM German Deutsche Marks</currency>
   <currency>GBP United Kingdom Pounds</currency>
   <currency>JPY Japanese Yen<currency>
   <currency>USD United States Dollars</currency>

Code (JavaScript):
xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
err = xml_doc.parseError;
if (err.errorCode != 0)
   alert("Error on line " + err.line + "\n" + err.srcText);

The alert displays the following message:

Error on line 8
   <currency>JPY Japanese Yen<currency>

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information