Home Page                            Home | White Papers | Message Board | Search | Products | Purchase | News |  

 

Web Connection

Features

Documentation

Pricing

Purchase

Online Demos

Customers

Support

What's new

 

Powered by Web Connection

Best viewed with Internet Explorer

Last updated: 09/17/01

 

 

msXML Bug Information


Due to many questions regarding the msXML parser bug that causes VFP clients to crash, this page has been made available to provide information on the bug and a patch file that Microsoft has made available.

To fix these problems it's highly recommended that you install the MSXML3 (or later) update of the parser which brings the Microsoft XML parser up to the latest version and fixes this particular problem. You can download this update from:

http://msdn.microsoft.com/xml/general/xmlparser.asp

A redistributable which you can distribute with your apps is also available from:

http://msdn.microsoft.com/xml/articles/msxmlcabfile.asp

The bug is described in the following knowledgebase article at http://msdn.microsoft.com. Search on the following ID:

Q255953 
LoadXML via Invoke returns S_FALSE when loading
invalid xml where 5.0 always returned S_OK.

This page describes a patch file that can be ordered from Product Support Services. However, this patch can be superseded by the MSXML 3 update.

The issue:
There is a bug in the MSXML.DLL file distributed by Microsoft with Internet Explorer 5.01 and also the shipping version of Windows 2000. This bug causes an unhandled COM exception (OLE Error 1) whenever a non-existant node, attribute, collection or element is accessed. These operations should normally return NULL, but instead the Error 1 is raised and no value is returned. This error manifests itself in any COM client other than VB/VBScript. VB/VBScript apparently ignores COM Error 1 as part of the language.

This problem will show in Visual FoxPro applications with a number of code scenarios. A simple repro scenario is the following:

lcXML = [<?xml version="1.0"?><root><data>somedata</data></root>]
loXML = CREATEOBJECT("Microsoft.XMLDOM")
loXML.loadXML(lcXML)
? loXML.parseError.reason && Bombs

Trying to access the parseError object which has not been initialized results in a COM exception. The proper result for this type of operation would be a blank string. Note that any properties of the object will cause this failure.

More importantly this problem occurs when you look for nodes in the XML content that aren't there. Assuming the above XML:

loDocRoot = loXML.documentElement
lcValue = loDocRoot.selectSingleNode("data") && returns 'somedata'
lcValue = loDocRoot.selectSingleNode("notthere") && Bombs

The result of the last line of code should be a NULL value stored in lcValue, but instead the COM exception occurs and lcValue is left unchanged. Along the same lines digging into childnode collections that don't exist cause these same type of errors - basically any operation that normally should return NULL will bomb. This makes it very difficult to parse documents that have dynamic structure with nodes that may or may not be there.

Working around this bug
This bug may not be a problem for you if you always deal with documents that have fixed structure and you never access nodes that aren't there. Also, you can't access essentially uninitialized values such as the parseError object. Otherwise you can work around this problem by wrapping all of your XML access into error handlers. This is messy at best and relies on the assumption your code is otherwise solid and doesn't error.

However, I wouldn't recommend this. Microsoft has acknowledged this bug and at the time of this writing has fixed it (see Knowledgebase article above). 


The West Wind Team