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

Reading XML file and exporting onto an Access db 1

Status
Not open for further replies.

Jayson

Programmer
Jan 31, 2001
75
0
0
US
Hi there,

I'm trying to build an application which basically needs to read in an XML document, extract the necessary data, and export it an an Access database, and ultimate product a Crystal Report from the info from the database.

Note, the XML document is very large and that the "wanted" data are spread out accross the nested XML tags, how do i go about grabbing only the data that i want? and then exporting those data on appropriate fields on an Access table?

Thanks for any suggestion.
 
Yes, I'm using C# for this. I'm looking at .Net libraries called: XPath, XmlNodeReader, XmlDataDocument. In conjunction, these seems to do what i want, but how would I go about grabbing the elements that i want, and then inserting them onto the appropriate fields inside the Access table.

Or am I going about this the right way? Do I actually need an Access database to produce the Crystal Report in the first place?

Thanks!
 
OK, the general idea is to use a XmlValidatingReader object along with a XmlTextReader object to read your file a little bit at a time. For each node that gets read (and the node could one be of several different types - elements, attributes, comments, etc) you would append it to a StringBuffer (see the example for XmlValidatingReader.Read method in the .NET help).

When you saw that you got the end element node for your XML record (like </Customer>), you would then load it into a XmlDocument object via the Load method (one of it's overloads takes a String), and then use XPath queries against your document to extract the elements you're interested in, and write them to your Access database.

Chip H.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top