The ParseError object returns detailed information about the last error.
XML:
<States>
<State ref="FL">
<name>Florida</name>
<capital>Tallahassee<capital>
</State>
<State ref="IA">
<name>Iowa</name>
<capital>Des Moines</capital>
</State>
</States>
VBScript:
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("states.xml")
If objXMLDoc.parseError.errorCode <> 0 Then
MsgBox("Parse Error line " & objXMLDoc.parseError.line & ", character " &_
objXMLDoc.parseError.linePos & vbCrLf & objXMLDoc.parseError.srcText)
End If
Parse Error line 7, character 32M
<capital>Tallahassee<capital>
This example checks for parse errors immediately after loading the XML file, and if there are any, displays a message box listing the line number, character position and text where it occurred:
Syntax: parseError.errorCode
This property is read-only and contains the error code of the last parse error.
Syntax: parseError.filepos
This property contains the absolute file position where the error occurred.
Syntax: parseError.line
This property returns the number of the line that contains the parse error.
Syntax: parseError.linepos
This property contains the position of the character within the line where the parse error occurs.
Syntax: parseError.reason
This property returns a string detailing the reason for the error.
Syntax: parseError.srcText
This property returns the full text of the line containing the error as a string.
Syntax: parseError.url
This property contains the URL of the XML document containing the last error.