Link to home
Start Free TrialLog in
Avatar of centralmike
centralmike

asked on

microsoft access - xml

I am trying to import xml file into a access to do reporting of the file.  When I import the file they are just tables with no relationship between the tables. Does anyone no how to import an create relationships between the tables.  The vendor did send me a xsd file also.  I will enclose the database and xml for example.
xmlfile.accdb
20160915-Generic-Life-Message.xml
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

you can use XSLT to transform the XML into a different format for Access
Avatar of centralmike

ASKER

can you show me an example in the database I sent you?  I tried transform an nothing change in the import. can you write down the steps to create the xlst file
FWIW, I tried to do what you want a few years back, and I never could get Access to import the XML correctly using the builtin methods. I ended up creating code to read the files and create records directly, using the XMLDOM methods. I used this to create the code:

https://msdn.microsoft.com/en-us/library/aa468547.aspx

The code snippet toward the bottom, in the section titled "How do I Traverse a Document" should give you a good starting point. It shows how to load an XML document and "walk" the nodes.
Scott ,I tried loading the xsd file into the database.   All the tables come in empty.  I can view the xsd file in notepad and all the elements show values attached to them.  Is there something special you have to do to load the xsd file into access.  I will attach the xsd file if you can take a look.
TXNewBus2.24.00.xsd
I can pretty much guarantee your file won't work. Access is very, very particular about the format needed for XML imports, and that format is nothing close. Below is an example of an XML file I just exported from an Access database:

<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="tCustomers.xsd" generated="2016-11-13T11:17:43">
<tCustomers>
<ID>1</ID>
<Customer>Bob&apos;s Anglers</Customer>
<Code>BAA</Code>
</tCustomers>
<tCustomers>
<ID>2</ID>
<Customer>House of Fish</Customer>
<Code>HOF</Code>
</tCustomers>
<tCustomers>
<ID>3</ID>
<Customer>The Fishing Boat</Customer>
<Code>TFB</Code>
</tCustomers>
</dataroot>

Open in new window


Your data would have to look very much like that in order for Access to import it, and given the XSD file you uploaded yours would certainly not look like that.
Scott, I think I am starting understand.  I notice in sample file you had ID element.  That's  look the key that would join the tables together.   So is there i way to insert an xml file an create primary an foreign keys to tables for linking relationships.
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the references to my questions.