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

Reading XML data

Status
Not open for further replies.

NewTerminator

Programmer
Apr 28, 2003
22
IN
I have a XML document that looks like the one below:

<rootelement>
<elementparent>
<child1>child1 </child1>
<child2>child2 </child2>
</elementparent>
<elementparent>
<child1>child1 </child1>
<child2>child2 </child2>
<child3>
<subchild>Testing</subchild>
</child3>
</elementparent>

</rootelement>

I would like to store these element information into the database. The example that has been displayed on top is a small part of a huge XML document that drills down to several inconsistent child nodes (like child3 above). Is there anyway i can read the data from the XML elements and store them in the database without using DOM?

I want to use Microsoft technologies to solve the problem.

Any help will be greatly appreciated
 
Take a look at the SAX parser (part of MSXML library).

What you do is point the .Parse method at your file, and it then raises events which you handle. The event you'll be most concerned with is EndElement, in which you look for the element corresponding to the end of your record. At that point you create your INSERT statement and send the data off to the database.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top