Click or drag to resize

Functions.XmlToCursor Method

-- todo --
Converts XML text into a X# cursor or table.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.17
 FUNCTION XmlToCursor(
Request Example View Source


eExpression (Optional)
Type: Usual
Specifies the XML text or an expression that evaluates to valid XML data. The eExpression parameter can be a X# 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.
Note Note
XMLTOCURSOR( ) generates an error if eExpression is not found or if eExpression does not parse to valid XML.
cCursorName (Optional)
Type: Usual
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, X# closes the cursor and creates a new one in an unused work area. If you omit or pass an empty string ("") for cCursorName, X# creates a cursor named "XMLRESULT" for returning the result.
If cCursorName contains data and nFlags is set to 8192, X# 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 (""), X# imports XML into the table or cursor that is open in the current work area.
nFlags (Optional)
Type: Usual
Specifies how XMLSource eExpression is handled in XMLTOCURSOR( ). The table in the remarks section describes the values for nFlags.

Return Value

Type: Long
Numeric data type. XMLTOCURSOR( ) returns the number of records created.
You can use XMLTOCURSOR( ) with the OLE DB Provider for X#. However, the _VFPVFPXMLProgID property is not supported because the _VFP system variable is not supported in the OLE DB Provider.
To use the X# OLE DB Provider with XMLTOCURSOR( ), you must install MSXML 3.0 on the computer with the OLE DB Provider.

XMLTOCURSOR( ) generates a syntax error for record lengths greater than approximately 160 columns. The exact number of columns that cause an error depends on the length of the column names.

XMLTOCURSOR( ) does not use the Varchar type when creating a cursor from an XML document. However, XMLTOCURSOR( ) supports appending data into an existing cursor with Varchar fields.
When calling XMLTOCURSOR( ) in append mode, X# adds an empty row if no XML element name matches any table or cursor column.

XMLTOCURSOR( ) converts Decimal data type to Numeric 20,19 (width, precision). In versions prior to X# 8.0, Decimal mapped to Numeric 8,0.

Numeric Overflow ConditionsXMLTOCURSOR( ) imports XML data containing X# numeric overflow conditions, for example, "*******", in place of a numeric or integer value. If a schema is provided, X# creates the correct data type in the resulting cursor but changes the overflow from asterisk (*) characters to 0.0 or 0 values. Therefore, the XML parser used by XMLTOCURSOR( ) does not throw an error as a result of character values stored in a decimal type element.
For more information about converting XML to X# data, see Converting Between XML and X# Data.
00000(Default) Treats the first parameter as a string containing XML data.
40100Preserves white space in data and overrides the xml:space attribute of the XML data.
51201000000000 Specifies that the first parameter, either an eExpression or a cXMLFile, is a string containing the name and path of an XML data file.
102410000000000 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.
2048100000000000 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 X# Currency data type in the resulting cursor.
40961000000000000 Disables base64 decoding.
In X#, base64 encoding is intended for encoding only binary data.
81921100000000 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.
327680x8000Indicates that a code page should be used.
655360x10000Maps XML Char fields to native Fox Varchar fields. If not specified, XML Char fields are mapped to Fox Character fields.
1310720x20000 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:
    The following table describes data type matching restrictions when setting nFlags to 8192.
    X# data typeBehavior
    Character, Character (Binary), Memo, Memo (Binary) Accepts any data but truncates any data exceeding the length of a Character column.
    Currency Accepts numeric data within accepted range of the Currency type but truncates numbers outside this range.
    Date Accepts XML format date and dateTime values.
    X# converts the XML date and dateTime formats to the corresponding X# date. X# preserves only the M/D/Y portion of the XML date or dateTime value.
    DateTime X# converts the XML date and dateTime formats to the corresponding X# date and discards precision beyond the extent supported by X#.
    Real8 Accepts numeric data within the accepted range of the Real8 type but truncates numbers outside this range.
    Integer Accepts integer data within the accepted range of the Integer type but truncates numbers outside this range.
    LogicalAccepts 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 X# rules or replaces with the numeric overflow indicator ("*************").
See Also