Microsoft KB Archive/320128

= FIX: The XMLToCursor Function Causes a Fatal Exception If the Root Tag Is Missing =

Article ID: 320128

Article Last Modified on 5/17/2002

-

APPLIES TO


 * Microsoft Visual FoxPro 7.0 Professional Edition

-



This article was previously published under Q320128



SYMPTOMS
If you use the XmlToCursor function to write a string of XML data to a cursor, the following error is returned:

Fatal error: Exception code=C0000005

This error occurs if the [] root tags are not contained in the XML string.



RESOLUTION
To resolve this problem, obtain the latest service pack for Visual FoxPro for Windows 7.0. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

316964 How to Obtain the Latest Visual FoxPro for Windows 7.0 Service Pack



WORKAROUND
To work around this issue if you have not installed Visual FoxPro 7.0 Service Pack 1 (SP1), add the  tag to the beginning of the string and add the  tag to the end of the string. This permits the cursor to be created. The following sample code demonstrates this method: * If the myXmlString string does not contain the root tags in the string: myXmlString = [] myXmlString = [] + myXmlString + [] ? XMLTOCURSOR(myXmlString, &quot;mycursor&quot;)
 * Add them by using the following code:
 * If it works, 1 is returned (meaning that one record has been created).
 * Otherwise, 0 is returned (meaning that it did not succeed).



STATUS
Microsoft has confirmed that this is a problem in Microsoft Visual FoxPro for Windows 7.0. This problem was first corrected in Visual FoxPro for Windows 7.0 Service Pack 1.



Steps to Reproduce the Problem
 Start Visual FoxPro version 7.00.0000.9262.  Create a program, add the following sample code, and then run the program from the Command window: myXmlString = [<myTable my_fld1 = &quot;ABCDE&quot; />] ? XMLTOCURSOR(myXmlString, &quot;mycursor&quot;) The error that is mentioned in the &quot;Symptoms&quot; section appears.

Note that if you run this after you install SP1, a 0 (zero) value is returned because no records were created. Installing SP1 prevents the error, but the root tags are still required for the XmlToCursor function to operate properly. If you change the code to the code that is listed in the &quot;Workaround&quot; section of this article, a one-record cursor is created in Visual FoxPro 7.0 SP1. </li></ol>

Keywords: kbbug kbfix kbvfp700sp1fix kbcodesnippet KB320128

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.