Converts XML text into a Visual FoxPro cursor or table.

XMLTOCURSOR(eExpression | cXMLFile [, cCursorName [, nFlags ]])



Specifies the XML text or an expression that evaluates to valid XML data. The eExpression parameter can be a Visual FoxPro memory variable, memo field contents, the return from an HTTP request, the return result from a SOAP method call, XML from the XMLDOM, or an ADO stream.


XMLTOCURSOR( ) generates an error if eExpression is not found or if eExpression does not parse to valid XML.


Specifies the name, and, optionally, the path of a physical XML file that resides on your local computer or network.

If you do not specify a path, Visual FoxPro searches the path along the Visual FoxPro directory for the XML file.


Specifies the name of the cursor to store the result and creates the cursor in the current work area.

If the cursor name already exists or is open, Visual FoxPro closes the cursor and creates a new one in an unused work area. If you omit or pass an empty string ("") for cCursorName, Visual FoxPro creates a cursor named "XMLRESULT" for returning the result.

If cCursorName contains data and nFlags is set to 8192, Visual FoxPro appends the data being imported from the XML file to the existing table or cursor. The table or cursor must be open or in use. If cCursorName is an empty string (""), Visual FoxPro imports XML into the table or cursor that is open in the current work area.


Specifies how XMLSource eExpression is handled in XMLTOCURSOR( ). The following table describes the values for nFlags.

nFlags Bit Description



(Default) Treats the first parameter as a string containing XML data.



Preserves white space in data and overrides the xml:space attribute of the XML data.



Specifies that the first parameter, either an eExpression or a cXMLFile, is a string containing the name and path of an XML data file.



NOCPTRANS – Creates Character and Memo fields in the resultant cursor with the NOCPTRANS option and inserts the text or XML values in the incoming elements into the Character or Memo field on an untranslated, byte-for-byte basis.

When used with flag 1024, XMLTOCURSOR( ) returns a string padded with trailing spaces equal to the actual string, that is, a string twice the length.



Use when the imported schema has an XML schema definition (XSD) schema containing decimal data type with restrictions, or facets, of totalDigits="19" and fractionDigits="4."

XSD data type values are mapped to the Visual FoxPro Currency data type in the resulting cursor.



Disables base64 decoding.

In Visual FoxPro, base64 encoding is intended for encoding only binary data.



Specifies that cCursorName is the name or alias of an existing table or cursor and imports the data from the specified XML file into an existing table or predefined cursor.

If cCursorName contains data, the data imported from the XML file is appended to the existing data. If cCursorName is an empty string (""), the data from the XML file is imported into the table or cursor in the current work area.

Setting nFlags to 8192 can be useful when an XML schema is not available or not practical for use.



Indicates that a code page should be used.



Maps XML Char fields to native Fox Varchar fields. If not specified, XML Char fields are mapped to Fox Character fields.



Maps XML base64Binary fields to native Fox Varbinary fields if less than 255 bytes or Blob fields if greater than this length. If not specified, XML base64Binary fields are mapped to Fox Memo fields.

When you use flag 8192, be aware of the following:

  • You must make sure the table schema matches the incoming XML elements in the appropriate manner. Visual FoxPro enforces the data types in cCursorName as described in the Data Type Matching table in this topic but makes no other assumptions about data types. Attempting to import incompatible values generates the appropriate message.

  • If the XML contains or references a schema, and the data types in the schema conflict with the data types of the cursor or table, the data types in the cursor or table are used.

  • Element names in the XML file are mapped to the column names in cCursorName. In addition, Visual FoxPro imports only data from the element names in the XML file that match the column names in cCusorName.

  • The cursor or table can have fewer columns than those in the XML file, but it must have at least one matching column. The cursor or table can have additional columns that do not correspond to an element in the XML file.

  • If the table contains autoincrementing fields, XMLTOCURSOR( ) fails if AUTOINCERROR is set to ON. Setting AUTOINCERROR to OFF or turning off autoincrementing in the target table by using CURSORSETPROP( ) allows XMLTOCURSOR( ) to succeed. The target table's autoincrementing field or fields are incremented according to the values specified, and the values in the source table are not copied.

The following table describes data type matching restrictions when setting nFlags to 8192.

Visual FoxPro data type Behavior

Character, Character (Binary), Memo, Memo (Binary)

Accepts any data but truncates any data exceeding the length of a Character column.


Accepts numeric data within accepted range of the Currency type but truncates numbers outside this range.


Accepts XML format date and dateTime values.

Visual FoxPro converts the XML date and dateTime formats to the corresponding Visual FoxPro date. Visual FoxPro preserves only the M/D/Y portion of the XML date or dateTime value.


Accepts XML format date and dateTime values.

Visual FoxPro converts the XML date and dateTime formats to the corresponding Visual FoxPro date and discards precision beyond the extent supported by Visual FoxPro.


Accepts numeric data within the accepted range of the Double type but truncates numbers outside this range.


Accepts integer data within the accepted range of the Integer type but truncates numbers outside this range.


Accepts the values True, .T., 1, False, .F., and 0.

Numeric, Float

Accepts numeric data with or without decimals but truncates numbers outside the accepted range for these types according to Visual FoxPro rules or replaces with the numeric overflow indicator ("*************").

Expand imageReturn Value

Expand imageRemarks

Expand imageSee Also

© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic