wwxml::CursorToXML

This high level method creates a full XML document that exports a VFP cursor to an XML document. If you export the file with the nCreateDataStructure flag set to 1 the file will contain a Schema or 2 to contain a DTD that describes the data structure of the table.

XML created with this method can be converted back into a cursor by running XMLToCursor().

Note that the structure of the document is:

xml
xml
<docroot> <schema> (optional) </schema> <table> <row> <field></field> </row> <row> <field></field> </row> </table> </docroot>

You can create an embedded schema by setting the nCreateDataStructure property to 1. To create a DTD use a value of 2. Schemas are embedded and may not work in all but the latest XML parsers that support them. You can reference an external schema using the cSchemaUrl property. The schema should follow the rules of CreateDataStructureSchema.

o.cursortoxml(lcName, lcRowName, lnIndent, llNoHeader)

XML String

Parameters

lcName
Optional - element name used at the table level. Note this tag sits underneath the document root. (wwBanners in the example).

  • Default value:* The name of the current Alias().

lcRowName
Optional - The element name used for each row of the cursor.

  • Default value:* "row"

lnIndent
Optional - Indentation level to start with.

llNoHeader
Optional - Leave out the XML Header

Remarks

  • The document format hierarchy must be . Naming is not required as long as hierarchy is intact

  • All tags are created as lower case tags from fieldanames. Any tags you assign (docroot and row level) maintain their case.

  • The nCreateDataStructure flag determines whether a schema or DTD is created. The DTD or Schema contain the data structure for the cursor. Use this if you need to reassemble the table back into a cursor on the other end of a dynamic XML connection or Web request.

  • The data format may change in the future to conform to an XML data standard. The current implementation is built for maximum flexibility and performance and is mainly intended to allow reassembling of data on both ends of the connection. The structure is also built for extensibilty to allow combination of multiple cursors/object/XML fragments into a single document.

Example

use wwBanners

*** DTD example - (Schema version below) oXML = CREATE("wwXML") oXML.nCreateDataStructure = 2 && DTD ShowText( oXML.CursorToXML() ) <


>

]>

<tt_cust> 2 BGP Productions James Nolan

45 Labor_PRG 2 4 Golf Reproductions 42 ...

</tt_cust>

<


> *** Schema Version oXML = CREATE("wwXML") oXML.lCreateDataStructure = 1 && Schema ShowText( oXML.CursorToXML() ) <
>

<tt_cust> 2 BGP Productions James Nolan

45 Labor_PRG 2 4 Golf Reproductions ... </tt_cust>

See also

Class wwXML (High Level Methods)
wwXML::CreateCursorXML
wwxml::CreateDataStructureDTD
wwxml::CreateDataStructureSchema

© West Wind Technologies, 2025 • Updated: 2025-03-12
Comment or report problem with topic