Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NEED HELP TO IMPORT AN XML FILE TO A CURSOR 3

Status
Not open for further replies.

PatMcLaughlin

Programmer
Dec 10, 2010
97
US
Being a newby to fox pro and programing, I am having a horrendous time trying to figure out how to get an xml file sent to us by a third party into a cursor so I can append another document (dbf) with the imported data. The xml will never have all of the fields of the dbf, but the dbf will have the all of the fields in the xml. I don't understand enough to even get past the syntax errors trying to use 'xmltocursor' (foxprow 7.0).
 
Glad to hear you like VFP9. It's capabilites still are limited in regar to XML, but much better than in VFP7, where that just started off.

In regard to the closing question: No, XMLTOCURSOR cannot always convert to a cursor you prepare in advance, it can't turn text into integers or something like that kind of impossible type conversion of course.

And XMLTOCURSOR also is limited to xml representing a flat table. XML itself is capable to represent any hierarchical or more complex data structures, nested data needing parent and child table for example, but also data which wouldn't match into tables at all, eg think of a table more like excel, where a column can have a different datatype in each row, even in each cell. XML is no replacement for tables, like HTML is not. It's only used for data, it's not designed for it, at least not only.

Think of other uses of XML, like in Office formats since Office 2007, Word documents are XML mainyl, if you add the file extension .ZIP to a docx and unzip you'll see. And like you wouldn't try to insert a word document to a table, despite of into a binary field type like a binary memo field or BLOB, to store the whole file. You don't generally expect tabular data in a word document, it's just the exception, in general it's a text document. XML is often used in data transfer in webservices for example. But that's just because XML can be used to represent anything. It's working with the tag principle you know from HTML, but you can determine tag names, and are not limited to HTML tags. It's extensible, so you can define tags representing data, you can define what the tags mean, if data is between opening and closing tag or stored in attributes of the tag etc.

That's perhaps what is confusing poeple so much about XML. XML is universal, but as XML is universal, you cannot convert any XML into a single table, only XML that represents a single table.

I already said that way up, XMLTOCURSOR is no one size fits all function to turn any XML into a cursor.

Bye, Olaf.
 
Again Thank you both for your perseverence! I feel like I have found new friends.
 
One more thing about the BOM (Byte Order Mark) at the begin of that xml file and how it could have come into it:

If you start notepad, write seomthing then save and in the save dialog choose a Coding/Codepage other than ANSI, eg UTF-8, notepad writes out this BOM (
This is not desired for XML Parsers and also not for XMLTOCURSOR as it hinders to parse the xml file.

It might be, that the xml was edited with notepad or some other editor supporting aand writing out the bytemark, which renders the xml unusable for parsers.

This also means, that it's not always needed to remove the first three bytes of an XML file, only if these are a BOM not belonging to the XML.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top