XML DOM » ParseError » filepos

Compability: Internet Explorer

Syntax:
parseError.filepos

This property contains the absolute file position where the error occurred.

Examples

Code:
XML:

<Albums>
   <Album ref="CD720">
      <categor>Pop</category>
      <title>Come On Over</title>
      <artist>Shania Twain</artist>
   </Album>
   <Album ref="CD024">
      <category>Country</category>
      <title>Red Dirt Girl</title>
      <artist>Emmylou Harris</artist>
   </Album>
</Albums>

JavaScript:

xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
xml_doc.load("albums.xml");
err = xml_doc.parseError;
if (err.errorCode != 0) alert("File Position: " + err.filepos);
Output:
File Position: 164
Explanation:

In this example the file 'albums.xml' is loaded which includes an error: the letter 'y' has been omitted from the end of the opening 'category' tag of the first 'Album' element. If a parse error occurs, as it does in this case, an alert displays its file position.

Language(s): JavaScript XML