Partager via


ToXML Method

Generates XML to a file or memory variable.

XMLAdapter.ToXML( cXMLDocument [, cSchemaLocation [, lFile [, lIncludeBefore [, lChangesOnly ]]]] )

Parameters

  • cXMLDocument
    Specifies the file or memory variable name for the XML document.

  • cSchemaLocation
    Specifies the location for a reference to external schema. The default value of cSchemaLocation is empty (""). If cSchemaLocation is empty and external schema has been generated, the value of XMLAdapterXMLSchemaLocation is used as the external schema reference.

  • lFile
    Specifies whether cXMLDocument is a file. The default value of lFile is False (.F.).

  • lIncludeBefore
    Specifies whether to include the diffgr:before section in the DiffGram. The diffgr:before section contains the original version of a row. The default value of lIncludeBefore is False (.F.).

    If lIncludeBefore is True (.T.), Visual FoxPro filters deleted records, regardless of the current filter setting, such as SET FILTER TO NOT DELETED( ) and SET DELETED ON or OFF. All deleted records in the table buffer are inserted in the diffgr:before section but have no matching row in the DiffGram DataInstance block.

    Although you might want to hide deleted rows by using a filter, the DiffGram indicates which rows were deleted so that the data source can be correctly updated.

    Visual FoxPro disregards lIncludeBeforeif the XMLAdapter IsDiffGram property is False (.F.).

  • lChangesOnly
    Specifies whether the XML should contain changes only.

    Visual FoxPro disregards lChangesOnlyif the XMLAdapter IsDiffGram property is False (.F.) or if lIncludeBefore is False (.F.).

Remarks

Applies To: XMLAdapter Class

If the XMLTable Alias property is empty, no XML elements are generated for that XMLTable object, however, the table is included in the schema if one is generated.

For character fields, Visual FoxPro fills any remaining space in the field with white space (0x20). When ToXML maps character fields to binary fields and performs encoding, ToXML encodes the trailing white space regardless of the value for the XMLAdapter PreserveWhiteSpace property.

The following XMLAdapter property settings affect how ToXML is executed:

Nested XML   When the XMLAdapter RespectNesting property is True (.T.) and a relationship between the tables is specified, ToXML generates nested XML. Nesting is not supported if the IChangesOnly parameter is set to True (.T.).

XML Encoding   When the XMLAdapter RespectCursorCP property is True (.T.), XMLAdapter UTF8Encoded is False (.F.), and two or more table aliases are referenced in the Tables collection, those tables should use the same code page. If you also set the UseCodePage property, the results generated by ToXML varies. See UseCodePage property for a table that shows the results.

Numeric Overflow Conditions   An XMLAdapter object does not load XML containing Visual FoxPro-type numeric overflow conditions, for example, *****.**, in the place of a Numeric or Integer value. The Microsoft XML Core Services (MSXML) parser causes an error similar to the following:

Error 2110 (XML Error): XML Error: XML Parse error: The value of '***' is invalid according to its data type.
The element: 'myfield' has an invalid value according to its data type.
Line 7, Position 17.
   <myfield>***</myfield>

If the XMLNameIsXpath property is True (.T.) for XMLAdapter or XMLTable object and the XMLName property is not empty, ToXML fails. ToXML ignores XMLField objects that use XPath expressions.

See Also

Reference

XMLAdapter Object Properties, Methods, and Events

IsDiffGram Property

Alias Property

XMLTable Class

Tables Collection (XMLAdapter)

Other Resources

Methods (Visual FoxPro)