PRB: No Access XML Object Model After Call to XML Parser Load() Method

ID: Q221841


The information in this article applies to:
  • Microsoft Internet Explorer (Programming) version 5.0


SYMPTOMS

The load() method returns successfully but errors occur when accessing the MSXML Document Object Model. The XML document is valid, well-formed, and it contains no errors.

This behavior may be intermittent and does not occur when loading the XML document from the local file system (file://).


CAUSE

By default, the XML parser loads and parses an XML file asynchronously over HTTP. This means that portions of the document's object model will not be available to code immediately after load returns.


RESOLUTION

To ensure the document is loaded, either:

  • Set the async property to false before calling the load() method.


  • OR

  • Handle the onreadystatechange event and check for the readystate property to be "complete" (value of 4).



MORE INFORMATION

Here is an example fragment of VBScript that uses the async property:


   Set xmlDoc = CreateObject("Microsoft.XMLDOM")
   xmlDoc.async = false
   xmlDoc.load strURLofXMLDoc 
Here is the equivalent solution in a Visual C++ host:

   MSXML::IXMLDOMDocumentPtr pDOMDoc(__uuidof(MSXML::DOMDocument));
   pDOMDoc->put_async(VARIANT_FALSE);
   VARIANT_BOOL varResult = DOMDoc->load(_variant_t(bstrURLofXMLDoc)); 


REFERENCES

For additional information about the asynchronous behavior of the Internet Explorer 5.0 XML parser, please see the following article in the Microsoft Knowledge Base:

Q223337 Loading/saving XML data using the Internet Explorer XML parser

For more information, please see the MSDN Web Workshop:
http://msdn.microsoft.com/workshop/default.asp

Additional query words: load IXMLDOMDocument

Keywords : kbGrpInet kbIE500 kbXML kbDSupport
Version : WINDOWS:5.0
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: July 27, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.