XML created with this method can be converted back into a cursor by running XMLToCursor().
Note that the structure of the document is:
<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)
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
use wwBanners
*** DTD example - (Schema version below)
oXML = CREATE("wwXML")
oXML.nCreateDataStructure = 2 && DTD
ShowText( oXML.CursorToXML() )
<!--- DTD version ---->
<?xml version="1.0"?>
<!DOCTYPE tt_cust [
<!ELEMENT tt_cust (customers)>
<!ELEMENT customers (customer)*>
<!ELEMENT customer (custno,company,careof,address,shipaddr,email,phone,billrate,btype,pk)>
<!ELEMENT custno (#PCDATA)>
<!ATTLIST custno
type CDATA #FIXED "string"
size CDATA #FIXED "8"
>
<!ELEMENT company (#PCDATA)>
<!ATTLIST company
type CDATA #FIXED "string"
size CDATA #FIXED "30"
>
<!ELEMENT careof (#PCDATA)>
<!ATTLIST careof
type CDATA #FIXED "string"
size CDATA #FIXED "30"
>
<!ELEMENT address (#PCDATA)>
<!ATTLIST address
type CDATA #FIXED "string"
size CDATA #FIXED "2147483647"
>
<!ELEMENT shipaddr (#PCDATA)>
<!ATTLIST shipaddr
type CDATA #FIXED "string"
size CDATA #FIXED "2147483647"
>
<!ELEMENT email (#PCDATA)>
<!ATTLIST email
type CDATA #FIXED "string"
size CDATA #FIXED "2147483647"
>
<!ELEMENT phone (#PCDATA)>
<!ATTLIST phone
type CDATA #FIXED "string"
size CDATA #FIXED "2147483647"
>
<!ELEMENT billrate (#PCDATA)>
<!ATTLIST billrate
type CDATA #FIXED "float"
size CDATA #FIXED "7"
precision CDATA #FIXED "2"
>
<!ELEMENT btype (#PCDATA)>
<!ATTLIST btype
type CDATA #FIXED "string"
size CDATA #FIXED "15"
>
<!ELEMENT pk (#PCDATA)>
<!ATTLIST pk
type CDATA #FIXED "i4"
size CDATA #FIXED "4"
>
]>
<tt_cust>
<customers>
<customer>
<custno> 2</custno>
<company>BGP Productions</company>
<careof>James Nolan</careof>
<address><![CDATA[34 Eastland Road
Suite C104
Diversion, MA 01111]]></address>
<shipaddr/>
<email/>
<phone><![CDATA[Voice: 312-233-3333
Fax: 312-232-3322
Data: 312-232-0001]]></phone>
<billrate>45</billrate>
<btype>Labor_PRG</btype>
<pk>2</pk>
</customer>
<customer>
<custno> 4</custno>
<company>Golf Reproductions</company>
<pk>42</pk>
...
</customer>
</customers>
</tt_cust>
*** Schema Version
oXML = CREATE("wwXML")
oXML.lCreateDataStructure = 1 && Schema
ShowText( oXML.CursorToXML() )
<?xml version="1.0"?>
<tt_cust>
<Schema name="Schema" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes">
<ElementType name="customers" content="eltOnly" model="closed" order="many">
<element type="customer" />
</ElementType>
<ElementType name="customer" content="eltOnly" model="closed" order="many">
<element type="custno"/>
<element type="company"/>
<element type="careof"/>
<element type="address"/>
<element type="shipaddr"/>
<element type="email"/>
<element type="phone"/>
<element type="billrate"/>
<element type="btype"/>
<element type="pk"/>
</ElementType>
<ElementType name="custno" content="textOnly" model="closed" dt:type="string">
<AttributeType name="type"/>
<attribute type="type" default="string"/>
<AttributeType name="size"/>
<attribute type="size" default="8"/>
</ElementType>
<ElementType name="company" content="textOnly" model="closed" dt:type="string">
<AttributeType name="type"/>
<attribute type="type" default="string"/>
<AttributeType name="size"/>
<attribute type="size" default="30"/>
</ElementType>
<ElementType name="careof" content="textOnly" model="closed" dt:type="string">
<AttributeType name="type"/>
<attribute type="type" default="string"/>
<AttributeType name="size"/>
<attribute type="size" default="30"/>
</ElementType>
<ElementType name="address" content="textOnly" model="closed" dt:type="string">
<AttributeType name="type"/>
<attribute type="type" default="string"/>
<AttributeType name="size"/>
<attribute type="size" default="2147483647"/>
</ElementType>
<ElementType name="shipaddr" content="textOnly" model="closed" dt:type="string">
<AttributeType name="type"/>
<attribute type="type" default="string"/>
<AttributeType name="size"/>
<attribute type="size" default="2147483647"/>
</ElementType>
<ElementType name="email" content="textOnly" model="closed" dt:type="string">
<AttributeType name="type"/>
<attribute type="type" default="string"/>
<AttributeType name="size"/>
<attribute type="size" default="2147483647"/>
</ElementType>
<ElementType name="phone" content="textOnly" model="closed" dt:type="string">
<AttributeType name="type"/>
<attribute type="type" default="string"/>
<AttributeType name="size"/>
<attribute type="size" default="2147483647"/>
</ElementType>
<ElementType name="billrate" content="textOnly" model="closed" dt:type="float">
<AttributeType name="type"/>
<attribute type="type" default="float"/>
<AttributeType name="size"/>
<attribute type="size" default="7"/>
<AttributeType name="precision"/>
<attribute type="precision" default="2"/>
</ElementType>
<ElementType name="btype" content="textOnly" model="closed" dt:type="string">
<AttributeType name="type"/>
<attribute type="type" default="string"/>
<AttributeType name="size"/>
<attribute type="size" default="15"/>
</ElementType>
<ElementType name="pk" content="textOnly" model="closed" dt:type="i4">
<AttributeType name="type"/>
<attribute type="type" default="i4"/>
<AttributeType name="size"/>
<attribute type="size" default="4"/>
</ElementType>
</Schema>
<customers xmlns="x-schema:#Schema">
<customer>
<custno> 2</custno>
<company>BGP Productions</company>
<careof>James Nolan</careof>
<address><![CDATA[34 Eastland Road
Suite C104
Diversion, MA 01111]]></address>
<shipaddr/>
<email/>
<phone><![CDATA[Voice: 312-233-3333
Fax: 312-232-3322
Data: 312-232-0001]]></phone>
<billrate>45</billrate>
<btype>Labor_PRG</btype>
<pk>2</pk>
</customer>
<customer>
<custno> 4</custno>
<company>Golf Reproductions</company>
...
</customer>
</customers>
</tt_cust>