DOM
Expand Minimize

parseError Property

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

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.3.0");
var myErr;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   myErr = xmlDoc.parseError;
   if (myErr.errorCode != 0) {
      WScript.Echo("You have error " + myErr.reason);
   }
}


Set objError = objXMLDOMDocument.parseError

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.


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.


The property is read-only. It returns IXMLDOMParseError.

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

Implemented in:

MSXML 3.0, MSXML 6.0

Show:
© 2015 Microsoft