Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XML Import in Access 2003

12 views
Skip to first unread message

David Sigmon

unread,
Oct 17, 2003, 1:54:59 PM10/17/03
to
I have been trying to import an xml document into Access
2003. I have been able to get it to import the data into
multiple tables that make seem to align with the .xml
format of the file. But any relations between the tables
has been lost. It is easy to see the relations in
the .xml document but no luck on import.
Any suggestions?

Joe Fallon

unread,
Oct 17, 2003, 11:28:12 PM10/17/03
to
Are you creating new tables "on the fly" during the import?

Or do the tables already exist with pre-defined relationships and the import
is destroying them?
--
Joe Fallon
Access MVP

"David Sigmon" <anon...@discussions.microsoft.com> wrote in message
news:2a4001c394d7$c889cf20$7d02...@phx.gbl...

anon...@discussions.microsoft.com

unread,
Oct 20, 2003, 6:45:08 AM10/20/03
to
I have many files that i need to load into access tables.
I do not heve the tables or relationships created. I was
going to take the first XML file imported to establish the
tables and relationships. Access creates the tables and
puts the data into the tables but destroys the
relationships that you can see looking at the XML. If I
can get the tables and relationships established, I will
be appending many more XML files.

>.
>

Joe Fallon

unread,
Oct 20, 2003, 11:22:11 PM10/20/03
to
I think Access is making a "best guess" when it imports the XML files.
If it is "wrong" then it is up to you to correct the problem either in the
XML or in the Access tables (your choice.)

Try reversing the problem and build a correct Access database with some
sample data.
Then export it as XML.
Now check out the file structure.
Does the file you are trying to import look anything like that? (I doubt
it.)

Try importing the sample data and see if it goes into the right tables. If
it does then you know the correct format that Access is expecting.

1. Change your XML file to look like something Access is expecting.


2. You can leave your file "as is" but then when you import, consider the
tables it creates to be "staging tables".
Now write Append queries to move the data to the real tables.

--
Joe Fallon
Access MVP

<anon...@discussions.microsoft.com> wrote in message
news:040201c396f7$3b0026a0$a001...@phx.gbl...

Mike Wachal [MSFT]

unread,
Oct 22, 2003, 7:05:57 PM10/22/03
to
Hi David and Joe,

Access 2003 (or 2002 for that matter) does not create relationships between
tables when importing from XML. As Joe suggested, when importing arbitrary
XML, Access makes a best guess as to how many tables should be created from
the XML. When importing Access created XML, you should get back the exact
same table structure that was used to export to XML, but the relationships
will be lost.

Regards,
Mike Wachal
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.


"Joe Fallon" <jfal...@nospamtwcny.rr.com> wrote in message
news:eyt8EK4l...@TK2MSFTNGP12.phx.gbl...

Joe Fallon

unread,
Oct 22, 2003, 7:50:13 PM10/22/03
to
Mike,
Please confirm:

1. If I have an existing table structure with proper relationships and I
export the data to XML and then re-import it the relationships are *still*
present.
(The import does not destroy the relationships.)

2. However, if I import the XML to a NEW .mdb file the tables are built but
the relationships are NOT built.


--
Joe Fallon
Access MVP

"Mike Wachal [MSFT]" <mik...@online.microsoft.com> wrote in message
news:ePnXOEPm...@TK2MSFTNGP10.phx.gbl...

Mike Wachal [MSFT]

unread,
Oct 23, 2003, 7:58:23 PM10/23/03
to
Hi Joe,

It's probably easier is I give you a set of scenarios and tell you what the
expected results in each case will be:

For each scenario, assume that I started with Table1 and Table2, which are
related to each other. I exported Table1 to XML (table1.xml) and selected
the option in the dialog to also export Table2 using the "Related Tables"
list.

Scenario1: Import table1.xml into my database and use the options to append
the data to the existing Table1 and Table2. (Assume there won't be any weird
key conflicts) The existing relationships between Table1 and Table2 are
preserved.

Scenario2: Import table1.xml in my database and use the option to import
structure and data, which is going to create two new tables. I end up with
tables named Table11 and Table21 (since Table1 and Table2 already exists),
there are no relationships between Table11 and Table21, but all the data is
there.

Scenario3: Import table1.xml into a blank database. I end up with Table1 and
Table2, but there are no relationships between the tables.

So the short answer is that there is no relationship information included in
an XML file, even when you choose to export schema. Since that information
is not in the file, it can not be recreated from the file.

Regards,
Mike Wachal
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.

"Joe Fallon" <jfal...@nospamtwcny.rr.com> wrote in message

news:eY1i7cPm...@TK2MSFTNGP12.phx.gbl...

Joe Fallon

unread,
Oct 24, 2003, 12:08:10 AM10/24/03
to
Thanks Mike.
BTW - you confirmed my scenarios.

It is exactly as I expected.
Thanks!


--
Joe Fallon
Access MVP

"Mike Wachal [MSFT]" <mik...@online.microsoft.com> wrote in message

news:uQGeSGc...@TK2MSFTNGP09.phx.gbl...

will eichert

unread,
Nov 21, 2003, 4:45:27 PM11/21/03
to
I'm pretty new to this stuff, so forgive if this is a stupid question,
but I'm wondering why Access doesn't accept a schema file as a
parameter when you import an XML file, and use the relationships in
the schema file to map an XML file correctly to the database? The
schema file would certainly know about the relationships, especially
if you created it from the Access table(s) in the first place, no?

Thanks,

Will

Mike Wachal

unread,
Nov 21, 2003, 9:04:20 PM11/21/03
to
Hi Will,

Access supports the use of schemas in two ways:

1) A separate schema file identified within the XML file as such:

<dataroot xmlns:od="urn:schemas-microsoft-com:officedata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Orders.xsd" generated="2003-11-21T17:48:23">

Note that Orders.xsd is specified as the schema file

2) Schema embedded directly in the XML file.

Access does not read relationship information from the schema nor it does
write relationship information when exporting to XML.

--

Regards,
Mike Wachal
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.

will eichert

unread,
Nov 24, 2003, 1:33:59 PM11/24/03
to
OK, thanks for the info. I incorrectly assumed table relationships
would be in xml schemas.

Will

0 new messages