PROPERTY:  ParseError::linepos

This property is a Microsoft extension to the W3C DOM.


The linepos property is read-only and contains the position within the line of the character causing the parse error.

In the following example the file 'staff.xml' is loaded which includes an error: the slash character (/) is missing from the closing 'name' tag of the second 'employee' 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 offending character's position within that line.

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

   <employee ssn="123456" pay="3">
      <name>John Sullivan</name>
      <position>senior executive</position>
   <employee ssn="987654" pay="2">
      <name>Mary Lopez<name>
      <position>personal assistant</position>

Code (JavaScript):
xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
err = xml_doc.parseError;
if (err.errorCode != 0)
   alert("Line: " + err.line + "\nLine Position: " + err.linepos);

The alert displays the following message:

Line: 10
Line Position: 25

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