0

I try to use XMLTOCURSOR() in VFP 9.2. There is an error 'xml parse error xml document must have a top level element. Line 0, position 0 (null)'

if I use ?XMLTOCURSOR('your.XML', 'test', 512), it returns one row

here is my file, your.xml:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>  <Donnees>
    <DonneesAsset>
        <Asset>RPF 052_V3</Asset>
        <Date Jour='8' Mois='4' Annee='2009' Heures='10' Minutes='11' Secondes='50'/>
        <Mesure>
            <Capteur>Report</Capteur>
            <Enrichie>Scheduled</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>Customer Proximity</Capteur>
            <Enrichie>At 22,1 km South East from EBTS Hasselt</Enrichie>
            <Unite>km</Unite>
        </Mesure>
        <Mesure>
            <Capteur>Proximity Eurocities</Capteur>
            <Enrichie>At 17,4 km North West from Liege -- Belgium --</Enrichie>
            <Unite>km</Unite>
        </Mesure>
        <Mesure>
            <Capteur>Customer Zone</Capteur>
            <Enrichie>Maasmechelen Zone - St Truiden Zone - V3 Kiewit Zone</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>Speed avg</Capteur>
            <Enrichie>42,1</Enrichie>
            <Unite>km/h</Unite>
        </Mesure>
        <Mesure>
            <Capteur>Movement GPS</Capteur>
            <Enrichie>Driving</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>City</Capteur>
            <Enrichie>Tongeren</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>Code</Capteur>
            <Enrichie>3700</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>Country</Capteur>
            <Enrichie>Belgium</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>Position GPS</Capteur>
            <Enrichie>50.76619N 5.4713593E</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>Speed</Capteur>
            <Enrichie>40</Enrichie>
            <Unite>km/h</Unite>
        </Mesure>
        <Mesure>
            <Capteur>Heading</Capteur>
            <Enrichie>NE</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>Distance</Capteur>
            <Enrichie>13</Enrichie>
            <Unite>km</Unite>
        </Mesure>
        <Mesure>
            <Capteur>Distance timer</Capteur>
            <Enrichie>17</Enrichie>
            <Unite>min</Unite>
        </Mesure>
        <Mesure>
            <Capteur>Door</Capteur>
            <Enrichie>CLOSED</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>Ignition</Capteur>
            <Enrichie>ON</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>Compressor</Capteur>
            <Enrichie>OFF</Enrichie>
        </Mesure>
        <Mesure>
            <Capteur>PWR Supply</Capteur>
            <Enrichie>EXTERNAL</Enrichie>
        </Mesure>
    </DonneesAsset>
</Donnees>
user1188125
  • 677
  • 2
  • 13
  • 21

1 Answers1

2

That's because you have only one element inside the top level. That is, you have the top level as Donnees and inside that, there's a single DonneesAsset record.

Try using the XMLAdapter class instead. It has a lot more flexibility.

Tamar E. Granor
  • 3,817
  • 1
  • 21
  • 29
  • If you use 'TEXT TO cXML' to create and execute, it has no problem. But when you save the xml into a file, then you get the same error. – user1188125 Mar 06 '13 at 14:34
  • If you're saying that the problem is that it can't find the file, check your parameters. You have to pass 512 as part of the third parameter to tell the function that it's looking for a file. – Tamar E. Granor Mar 06 '13 at 21:57
  • It seems to be working if I use cursortoxml to create first and use xmltocursor to import it. I open the xml file created by cursortoxml and it is different format than the one I open above. I am not familiar with XML format. Can someone tell the difference? – user1188125 Mar 08 '13 at 14:07