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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML import not working

Status
Not open for further replies.

Donquick

Programmer
Aug 13, 2007
14
GB
Hi, just been trying to use the XML parser object(?) to import from a xml to a foxpro table. There is an example on the microsoft webite here :
After the code creates the object I have a problem. I have had a look in the debugger to see what is going on. The object is created, but the childnodes property is not created and if i try to watch the childnode property foxpro crashes and i have to restart.

In the microsoft example where you can display the number of nodes, the result i get is 1 which is wrong. The parser is only looking as deep as the item level. The first thing it does is tries to populate the field called "orders" (using thier example) without looking at the individual orders. This gives an error.

Anybody come accross this problem before ? I have updated to MSXMLparser V6 just for good measure but no joy.

Thanks,
 
In the microsoft example where you can display the number of nodes, the result i get is 1 which is wrong.

Are you sure? Without looking at your source XML document I can't be sure, but is it possible that there is an additional single node between the primary node and your field name and value nodes?

pamela
 
Hi Pamela,

Thanks for your reply. I have had a better look at the xml - you are spot on there is a second level property (or whtever you call it) encapsulating the whole list of items. So it has <channel> at the begining of the document after the first assignment and </channel> at the end. If i go in and remove these we have some success. (I am trying to write something automatic that doesn't need the use to edit the xml before using it to be honest but i will cross that bridge when i come to it)

However, there are still one or two problems. The tags in the xml are called things like <g:label> and <g:id> so i am having to write a case statement to accommodate this rather than just using the Nodename property for the table field name; as we cannot have an fp field called "g:label".

Also there are more than one tag called <label> for each item, so again more manual programming to introduce the required loop to populate all three leabl fields.

Anyway i have done all of this and the extract starts to work. It gets as far as the third item in the xml and then comes up with "lcVar is not an object" error after three sucessful iterations. Again if i try to watch the object in the debugger the whole of vfp locks up and i have to force close it.

There is a real problem creating the object somewhere. I can't imagine it is a memory issue. It is almost asif a loop is going out or bounds or something.

I am thinking about upgrade to vfp9 so i can use xmltocursor. Do you know if this is any more stable and capable of deboning the other issues like awkward and duplicate tag names and that duplicated opening tag <channel>.

Thanks again, all the best,

Magnus
 
I am thinking about upgrade to vfp9 so i can use xmltocursor. Do you know if this is any more stable and capable of deboning the other issues like awkward and duplicate tag names and that duplicated opening tag <channel>.
Yes, there have been many improvements in XMLToCursor over the versions, but XML is a very complex standard. Once you get past rather basic constructs, you need a schema for the source table to get you best results.
With complicated source, I still often use string parsing or instantiate the msxmlparser directly to interpret the data.

pamela
 
Hiya,

I now have version 9 and have tried the XMLtocursor function. It is failing at the first line at the moment. Do you know how to associate a schema to an xml file. I can't see mention of it on the xmltocursor() function reference .

All the best

Magnus
 
I would probably use the XMLAdapter class. It has an AddTableSchema method.

pamela
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top