Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2007, 11:22 AM
Registered User
 
Join Date: Oct 2007
Location: Dublin, Dublin, Ireland.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to upload complex xml file to 1 db table

I need to upload an XML file that contains multiple hierarchies, 4 tables if it was on a database into just 1 large table. How do I go about this through vb.net ... do I use XSLT, DOM, Xpath navigator, etc? If possible, I'd like to parse the file dynamically ie without having to hard code any of the node names into the VB code.
Thanks
Here is a sample of the XML

<?xml version="1.0"?>
<abcjob>
    <rptHdr>
        <rptNam>Daily Order Report</rptNam>
        <rptPrntRunDat>2007-09-26</rptPrntRunDat>
    </rptHdr>
    <abcjobGrp>
        <abcjobKeyGrp>
            <companyIdCod>ABC Company</companyIdCod>
        </abcjobKeyGrp>
        <abcjobGrp1>
            <abcjobKeyGrp1>
                <personIdCod>JohnH</personIdCod>
            </abcjobKeyGrp1>
            <abcjobGrp2>
                <abcjobKeyGrp2>
                    <prodIdCod>PC_07</prodIdCod>
                </abcjobKeyGrp2>
                <abcjobRec>
                    <tranDat>2007-09-26</tranDat>
                    <Id>1</Id>
                    <trdRptSts>P</trdRptSts>
                </abcjobRec>
                <abcjobRec>
                    <tranDat>2007-09-26</tranDat>
                    <Id>2</Id>
                    <trdRptSts>C</trdRptSts>
                </abcjobRec>
            </abcjobGrp2>
            <abcjobGrp2>
                <abcjobKeyGrp2>
                    <prodIdCod>PC_O8</prodIdCod>
                </abcjobKeyGrp2>
                <abcjobRec>
                    <tranDat>2007-09-25</tranDat>
                    <Id>1</Id>
                    <trdRptSts>P</trdRptSts>
                </abcjobRec>
            </abcjobGrp2>
        </abcjobGrp1>
        <abcjobGrp1>
            <abcjobKeyGrp1>
                <personIdCod>CliffC</personIdCod>
            </abcjobKeyGrp1>
            <abcjobGrp2>
                <abcjobKeyGrp2>
                    <prodIdCod>PC_08</prodIdCod>
                </abcjobKeyGrp2>
                <abcjobRec>
                    <tranDat>2007-09-26</tranDat>
                    <Id>1</Id>
                    <trdRptSts>P</trdRptSts>
                </abcjobRec>
                <abcjobRec>
                    <tranDat>2007-09-26</tranDat>
                    <Id>2</Id>
                    <trdRptSts>A</trdRptSts>
                </abcjobRec>
            </abcjobGrp2>
        </abcjobGrp1>
    </abcjobGrp>
</abcjob>
 
Old October 3rd, 2007, 03:05 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You could spend months trying to do that dynamically.

Without knowing how your table(s) are structured I would know where to start...



/- Sam Judson : Wrox Technical Editor -/
 
Old October 4th, 2007, 03:23 AM
Registered User
 
Join Date: Oct 2007
Location: Dublin, Dublin, Ireland.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The table I'm uploading to is a flat table equivalent of the XML file so there is a column for each element ie companyIdCod, personIdCod, prodIdCod, tranDat, Id, trdRptSts.

When I open the xml in MS Excel, companyIdCod, personIdCod, prodIdCod are repeated for each record and this is what I want to see on my DB table.
 
Old October 8th, 2007, 04:43 AM
Registered User
 
Join Date: Oct 2007
Location: Dublin, Dublin, Ireland.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Figured out how to do it using XSLT to convert it into a csv file that I can load into a string array and then to a datatable using an XSD.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating DB Table using XML inline schema info sriram_shol VB.NET 1 September 7th, 2012 01:08 PM
How do I export an access db table to xml? solos VB How-To 4 April 3rd, 2007 11:56 PM
Complex Table (at least for me) lcsgeek Classic ASP Basics 1 August 19th, 2003 02:53 PM
Complex table (at least for me) lcsgeek Classic ASP Professional 0 August 19th, 2003 10:13 AM
Complex HTML table (at least for me) lcsgeek Classic ASP Databases 1 August 19th, 2003 03:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.