parseError Property

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Reference

parseError Property

Returns an IXMLDOMParseError object that contains information about the last parsing error.

[Script]

Script Syntax

var objError = objXMLDOMDocument.parseError;

Example

The following script example uses the document's parseError property to create an IXMLDOMParseError object. It then tests the error and displays a message if one occurs.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var myErr;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode <> 0) {
   var myErr = xmlDoc.parseError;
   alert("You have error " + myErr.reason);
} else {
   myErr = xmlDoc.parseError;
   if (myErr.errorCode != 0) {
      alert("You have error " + myErr.reason);
   }
}
[Visual Basic]

Visual Basic Syntax

Set objError = objXMLDOMDocument.parseError

Example

The following Microsoft® Visual Basic® example uses the document's parseError property to create an IXMLDOMParseError object. It then tests the error and displays a message if one occurs.

Dim xmlDoc As New Msxml2.DOMDocument50
Dim myErr As IXMLDOMParseError
xmlDoc.async = False
xmlDoc.Load ("books.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
   Dim myErr
   Set myErr = xmlDoc.parseError
   MsgBox("You have error " & myErr.reason)
Else
   Set myErr = xmlDoc.parseError
   If (myErr.errorCode <> 0) Then
      MsgBox ("You have error " & myErr.reason)
   End If
End If
[C/C++]

C/C++ Syntax

HRESULT get_parseError(
    IXMLDOMParseError **errorObj);

Parameters

errorObj [out, retval]
The DOMParseError object. The errorObj parameter is always a valid object.

C/C++ Return Values

S_OK
The value returned if successful.
E_INVALIDARG
The value returned if the errorObj parameter is Null.

Example

IXMLDOMParseError *pIParseError = NULL;
HRESULT hr;
IXMLDOMDocument *pIXMLDOMDocument = NULL;
wstring strOutput = _T("Load Error");

   // Initialize pIXMLDOMDocument (create a DOMDocument).
   // Load document.
try
{
   hr = pIXMLDOMDocument->get_parseError(&pIParseError);
   SUCCEEDED(hr) ? 0 : throw hr;

   if(pIParseError )
   {
      hr = pIParseError->get_errorCode(&value);
      if(SUCCEEDED(hr))
      {
         strOutput = (value != 0) ? _T("Load Error") : _T("Load 
      Succeeded");
      }
      pIParseError->Release();
      pIParseError = NULL;
   }
}
catch(...)
{
   if(pIParseError)
      pIParseError->Release();
   DisplayErrorToUser();
}
// Release the IXMLDOMDocument interface when finished with it.

Remarks

The property is read-only. It returns IXMLDOMParseError.

This member is an extension of the World Wide Web Consortium (W3C) Document Object Model (DOM).

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

IXMLDOMParseError

Applies to: DOMDocument