Read XML into a DataSet

A

Allen Melendy

I need to read the sample XML data into SQL 7. Is there something wrong with
the XML file? I have tried every sample piece of code out there and I can't
get it to work.

I need to read the file into sql or dataset then move the file to another
folder then read the next file and so on. There may be up to 1,000 files to
read.

<order number>90052</order number>
<ship method>express</ship method>
<address>
<name>Some Name</name
<street>100 Any Street</street>
</address>
<order items>
<order item>
<qty>1</qty>
<image url>http://www.someweb.com/filename</image url>
</order item>
</order items>
 
W

W.G. Ryan MVP

There's a ton of stuff wrong with it unfortunately.
1- You have multiple top level elements when only one is allowed. You can
address this by creating a dummy element at the beginning and end of the
document. Add a <dummy> tag before </dummy> tag at the end
2- The name tag doesn't have a closing brace on the address node.
3- you have multiple elements with illegal names - if you remove the spaces
in them that will address the major issue.

If you use this, (of course, you can change the name <dummy> with whatever
made up name you want to indicate it's not a real node) it will work.
However this document would be a real pain in the butt to navigate and you
couldn't easily use an iterator. I'd really rethink the document structure
but that's another story. If you use this it will work:

<dummy>
<ordernumber>90052</ordernumber>
<shipmethod>express</shipmethod>
<address>
<name>Some Name</name>
<street>100 Any Street</street>
</address>
<orderitems>
<orderitem>
<qty>1</qty>
<imageurl>http://www.someweb.com/filename</imageurl>
</orderitem>
</orderitems>
</dummy>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top