FIX: LoadXML Returns S_FALSE for Invalid XML Document (255953)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft XML 2.5

This article was previously published under Q255953

SYMPTOMS

MSXML.dll version 5.0.2314 is included with Internet Explorer 5.0, MSXML.dll version 5.0.2919.6303 is included with Internet Explorer 5.01, and MSXML.dll version 5.0.2920 is included in Windows 2000.

When it calls LoadXML for an invalid XML document via IDispatch::Invoke(), MSXML.dll in Internet Explorer 5.0 returns S_OK. The same operation with Internet Explorer 5.01 and Windows 2000 MSXML.dll returns S_FALSE, which may cause applications (for example, Visual FoxPro) that depend on the result S_OK, to fail.

In Visual FoxPro, this bug causes an unhandled COM exception (OLE Error 1) whenever a nonexistent 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.

The following code provides a simple reproduction scenario:
lcXML = [<?xml version="1.0"?><root><data>somedata</data></root>]
loXML = CREATEOBJECT("Microsoft.XMLDOM")
loXML.loadXML(lcXML)
? loXML.parseError.reason	&& COM exception
loDocRoot = loXML.documentElement
lcValue = loDocRoot.selectSingleNode("data")	&& returns some data
lcValue = loDocRoot.selectSingleNode("notthere") && COM exception
				
When the line "? loXML.parseError.reason && COM exception" tries to access the parseError object, which has not been initialized, a COM exception occurs. The proper result for this type of operation would be a blank string. Note that any properties of the object will cause this failure. Additionally, 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.

RESOLUTION

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft Data Access Components service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this fix should have the following file attributes or later:
   Date      Version       Size            File name    
   -------------------------------------------------

   2/2/00    5.0.3014.200  522,000 bytes   msxml.dll
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

The fix is included with MSXML 2.5 Service Pack 1 and Windows 2000 Service Pack 1.

MORE INFORMATION


Modification Type:MinorLast Reviewed:10/12/2005
Keywords:kbHotfixServer kbQFE kbBug kbfix kbMSXMLnosweep kbQFE KB255953