Import XML into Access

G

Guest

I am trying to import xml data from the data source "C:\AudioTest.xml" into a
table named "Test" using the following code from the MSDN library but with no
success. When I add this to an Event to a button and then click it, Access
closes down due to an error. What is wrong here?

Private Sub Command1_Click()
'Purpose: Imports the data of an XML file.

Application.ImportXML _
DataSource:="C:\Audio\Test.xml", _
ImportOptions:=acAppendData

End Sub

Thank you in advance for your help.
 
G

Guest

hi,
Make sure that the table name is the root element of the XML file.
Also try importing the XML file using the import option that will guide you
through a series of options to import data. It can verify that data is in
propoer format and with well formed XML.

I am not sure which MSDN l;ibrary article you are referring to. Folloiwng
MSDN link is relevant and you may want to go through it.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ac2003_ta/html/odc_acxmlom.asp

Regards,
 
G

Guest

Design-Systems Team:

Thank you for your help. I think something else is going on in my database.
I tried the sample code (below and from the same link you sent me) and it
works perfectly fine using a brand new database, command button, and VB in an
On-Click event. However, when I use the code in my database, it will not
work. The system closes down completely and asks if I want to report the
error to Microsoft.

Do you know why this might be and how I can fix it? Thank you again.

Michelle
 
G

Guest

Try this:
Sub testimp()
Application.ImportXML DataSource:="C:\Inetpub\wwwroot\webstudents.xml",
ImportOptions:=acStructureAndData
End Sub

it will import into a table whose name is the name of repeated
node(corresponding to row) in the XML file.

Make sure your file name has no type.

For mroe informtion on Access get links from here:
http://hodentek.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top