I have a bunch of (flat) XML files such as:
<?xml version="1.0" encoding="UTF-8"?>
<SomeName>
<UID>
ID123
</UID>
<Node1>
DataA
</Node1>
<Node2>
DataB
</Node2>
<Node3>
DataC
</Node3>
<AnotherNode1>
DataD
</AnotherNode1>
<AnotherNode2>
DataE
</AnotherNode2>
<AnotherNode3>
DataF
</AnotherNode3>
<SingleNode>
DataG
</SingleNode>
</SomeName>
Now my actual XML files have too many nodes, so they can't be imported into a single table (due to the 255 column limit), so I need to split the data into multiple tables. I already created the tables by hand so now all access would have to do is match the Node names with the columns in each of the tables and copy the data.
It does so only for one table named 'SomeName', but leaves all other tables untouched.
I am unsure of how to get access to import my XML files properly into all the tables. I also already tried creating the UID field in each table and linking them (since the UID is unique to each XML dataset), but that left access unimpressed as well.
I've tried to find any sort of info on this problem, but have so far found nothing.
I would very grateful for any help or pointers.
Since you require more than 255 fields, you'll have to do this with code. You could load your XML into a
MSXML2.DOMDocument
, gather a subset of node values, build anINSERT
statement, and execute it.Here is a procedure I tested against your sample data. It's pretty ugly, but it works. Un-comment the
CurrentDb.Execute
line after you modifystrTagList
,strFieldList
,strTable
, andcintNumTables
and review theINSERT
statements. Add additionalCase
blocks if you have more than 2 tables to load.Here are 4 links I found helpful for VBA/XML/DOM: