Hi,
I am fairly new to the use of XML in FoxPro having only just got my hands on VFP9. I am now developing an application that will take an XML file convert to a VFP data set so that I can update the underlying data teir of the main application.
I will include the XML, the XSD and the code I am usingat the end of this post. The problem I have is that the resultant cursor only contains columns for the elements in the dochdr section of the XML and these are empty - no data in them at all.
CODE
XML
XSD
As I say the result is a table with only the dochdr elemetn as columns and no data in them.
Many thanks
Nathan
I am fairly new to the use of XML in FoxPro having only just got my hands on VFP9. I am now developing an application that will take an XML file convert to a VFP data set so that I can update the underlying data teir of the main application.
I will include the XML, the XSD and the code I am usingat the end of this post. The problem I have is that the resultant cursor only contains columns for the elements in the dochdr section of the XML and these are empty - no data in them at all.
CODE
Code:
LOCAL oXMLAdapter AS XMLADAPTER
oXMLAdapter = NEWOBJECT('XMLAdapter')
oXMLAdapter.RespectNesting = .T.
oXMLAdapter.XMLSCHEMALOCATION = "C:\Projects\Online Updates\EasyLink\Sample Data\finobj.xsd"
oXMLAdapter.LOADXML("C:\Projects\Online Updates\EasyLink\Sample Data\ELTestFile.xml", .T.)
IF oXMLAdapter.TABLES.ITEM(1).FIELDS.ITEM(1).DATATYPE <> "M" THEN
? 'Failed'
ELSE
oXMLAdapter.TABLES.ITEM(1).TOCURSOR(.F., "resultXML")
oXMLAdapter.XMLNAMESPACE=""
oXMLAdapter.RELEASEXML(.F.)
ENDIF
XML
Code:
<?xml version='1.0' encoding='utf-8'?>
<xmit>
<dochdr>
<application>COMTFR</application>
<userid>test mailbox</userid>
<doctitle>COMMISSION TRANSFER</doctitle>
<tranref />
<trandate>22/11/2005</trandate>
<trantime>01:35</trantime>
</dochdr>
<senderid>Scotish</senderid>
<userid>test mailbox</userid>
<icn>85</icn>
<apprefno>COMTFR</apprefno>
<test />
<doc>
<brokcode>115555</brokcode>
<inscode>165555</inscode>
<info>
<paydate>19/11/2005</paydate>
<agencyref>28460</agencyref>
<ifacode>115555</ifacode>
</info>
<policy>
<category>INITIAL</category>
<seq>1</seq>
<ifaref />
<polnum>4851234</polnum>
<schemenum>75999</schemenum>
<contype>GP-LINK</contype>
<polhold>SMITH-JONES ML</polhold>
<comlines>
<comln>
<comseq>1</comseq>
<commdate>24/10/05</commdate>
<freq>M</freq>
<pamt />
<comtype>Y</comtype>
<camt>-2.02</camt>
<currency>GBP</currency>
<reascd1>99</reascd1>
<reascd2>25</reascd2>
</comln>
</comlines>
</policy>
<policy>
<category>INITIAL</category>
<seq>2</seq>
<ifaref />
<polnum>4861234</polnum>
<schemenum>75999</schemenum>
<contype>GP-LINK</contype>
<polhold>SMITH-JONES L</polhold>
<comlines>
<comln>
<comseq>1</comseq>
<commdate>24/10/05</commdate>
<freq>M</freq>
<pamt />
<comtype>Y</comtype>
<camt>-0.65</camt>
<currency>GBP</currency>
<reascd1>99</reascd1>
<reascd2>25</reascd2>
</comln>
</comlines>
</policy>
<policy>
<category>INITIAL</category>
<seq>3</seq>
<ifaref />
<polnum>4891234</polnum>
<schemenum>75999</schemenum>
<contype>GP-LINK</contype>
<polhold>SMITH-JONES J</polhold>
<comlines>
<comln>
<comseq>1</comseq>
<commdate>24/10/05</commdate>
<freq>M</freq>
<pamt />
<comtype>Y</comtype>
<camt>-14.71</camt>
<currency>GBP</currency>
<reascd1>99</reascd1>
<reascd2>25</reascd2>
</comln>
</comlines>
</policy>
<policy>
<category>INITIAL</category>
<seq>4</seq>
<ifaref />
<polnum>4931234</polnum>
<schemenum>75999</schemenum>
<contype>GP-LINK</contype>
<polhold>SMITH-JONES J</polhold>
<comlines>
<comln>
<comseq>1</comseq>
<commdate>24/10/05</commdate>
<freq>M</freq>
<pamt />
<comtype>Y</comtype>
<camt>-3.53</camt>
<currency>GBP</currency>
<reascd1>99</reascd1>
<reascd2>25</reascd2>
</comln>
</comlines>
</policy>
<policy>
<category>INITIAL</category>
<seq>5</seq>
<ifaref />
<polnum>4951234</polnum>
<schemenum>75999</schemenum>
<contype>GP-LINK</contype>
<polhold>SMITH-JONES R</polhold>
<comlines>
<comln>
<comseq>1</comseq>
<commdate>24/10/05</commdate>
<freq>M</freq>
<pamt />
<comtype>Y</comtype>
<camt>-1.28</camt>
<currency>GBP</currency>
<reascd1>99</reascd1>
<reascd2>25</reascd2>
</comln>
</comlines>
</policy>
<policy>
<category>RENEWAL</category>
<seq>6</seq>
<ifaref />
<polnum>4971234</polnum>
<schemenum>70999</schemenum>
<contype>GP-LINK</contype>
<polhold>SMITH-JONES T</polhold>
<comlines>
<comln>
<comseq>1</comseq>
<commdate>04/11/05</commdate>
<freq>M</freq>
<pamt>455.75</pamt>
<comtype>R</comtype>
<camt>11.40</camt>
<currency>GBP</currency>
<reascd1>01</reascd1>
<reascd2>99</reascd2>
</comln>
</comlines>
</policy>
<policy>
<category>RENEWAL</category>
<seq>7</seq>
<ifaref />
<polnum>4301234</polnum>
<schemenum>72999</schemenum>
<contype>GP-LINK</contype>
<polhold>SMITH-JONES CS</polhold>
<comlines>
<comln>
<comseq>1</comseq>
<commdate>14/11/05</commdate>
<freq>M</freq>
<pamt>939.59</pamt>
<comtype>R</comtype>
<camt>9.39</camt>
<currency>GBP</currency>
<reascd1>01</reascd1>
<reascd2>99</reascd2>
</comln>
</comlines>
</policy>
<policy>
<category>RENEWAL</category>
<seq>8</seq>
<ifaref />
<polnum>4291234</polnum>
<schemenum />
<contype>PERPENS</contype>
<polhold>SMITH-JONES PJ</polhold>
<comlines>
<comln>
<comseq>1</comseq>
<commdate>20/11/05</commdate>
<freq>M</freq>
<pamt>500.00</pamt>
<comtype>R</comtype>
<camt>3.02</camt>
<currency>GBP</currency>
<reascd1>01</reascd1>
<reascd2>99</reascd2>
</comln>
</comlines>
</policy>
<policy>
<category>RENEWAL</category>
<seq>9</seq>
<ifaref />
<polnum>4821234</polnum>
<schemenum />
<contype>XLPLUS</contype>
<polhold>SMITH-JONES PR</polhold>
<comlines>
<comln>
<comseq>1</comseq>
<commdate>11/11/05</commdate>
<freq>M</freq>
<pamt>1862.00</pamt>
<comtype>R</comtype>
<camt>46.54</camt>
<currency>GBP</currency>
<reascd1>01</reascd1>
<reascd2>99</reascd2>
</comln>
</comlines>
</policy>
<totals>
<total1>
<totcomm>48.16</totcomm>
</total1>
<total2>
<commcf />
</total2>
</totals>
</doc>
</xmit>
XSD
Code:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="sample_x0020_XML_x0020_output_x0020_file.xml" xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
<xs:element name="xmit">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="dochdr">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="application" type="xs:string" />
<xs:element minOccurs="0" name="userid" type="xs:string" />
<xs:element minOccurs="0" name="doctitle" type="xs:string" />
<xs:element minOccurs="0" name="tranref" type="xs:string" />
<xs:element minOccurs="0" name="trandate" type="xs:string" />
<xs:element minOccurs="0" name="trantime" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="senderid" type="xs:string" />
<xs:element minOccurs="0" name="userid" type="xs:string" />
<xs:element minOccurs="0" name="icn" type="xs:string" />
<xs:element minOccurs="0" name="apprefno" type="xs:string" />
<xs:element minOccurs="0" name="test" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="unbounded" name="doc">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="brokcode" type="xs:string" />
<xs:element minOccurs="0" name="inscode" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="unbounded" name="info">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="paydate" type="xs:string" />
<xs:element minOccurs="0" name="agencyref" type="xs:string" />
<xs:element minOccurs="0" name="ifacode" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" maxOccurs="unbounded" name="policy">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="category" type="xs:string" />
<xs:element minOccurs="0" name="seq" type="xs:string" />
<xs:element minOccurs="0" name="ifaref" type="xs:string" />
<xs:element minOccurs="0" name="polnum" type="xs:string" />
<xs:element minOccurs="0" name="schemenum" type="xs:string" />
<xs:element minOccurs="0" name="contype" type="xs:string" />
<xs:element minOccurs="0" name="polhold" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="unbounded" name="comlines">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="comln">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="comseq" type="xs:string" />
<xs:element minOccurs="0" name="commdate" type="xs:string" />
<xs:element minOccurs="0" name="freq" type="xs:string" />
<xs:element minOccurs="0" name="pamt" type="xs:string" />
<xs:element minOccurs="0" name="comtype" type="xs:string" />
<xs:element minOccurs="0" name="camt" type="xs:string" />
<xs:element minOccurs="0" name="currency" type="xs:string" />
<xs:element minOccurs="0" name="reascd1" type="xs:string" />
<xs:element minOccurs="0" name="reascd2" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" maxOccurs="unbounded" name="totals">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="total1">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="totcomm" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" maxOccurs="unbounded" name="total2">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="commcf" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element msdata:IsDataSet="true" msdata:Locale="en-GB" name="sample_x0020_XML_x0020_output_x0020_file.xml">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="xmit" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
As I say the result is a table with only the dochdr elemetn as columns and no data in them.
Many thanks
Nathan