Link to home
Start Free TrialLog in
Avatar of drtopserv
drtopservFlag for Israel

asked on

Need Help in importing the xml and xsd into access

I can`t import the xml with the xsd into access, i got an error.
plz have a look at the file, and try to help me out how to fix the problem.
thnx in regard.
Sample1.xml
Sample2.xml
kmu.xsd
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

What is the source for the XML
How are you doing the conversion to XML
Avatar of drtopserv

ASKER

I have third party person sent the xml+xsd, it means this xml+xsd is how he need me to send  him the data,
i need to build a form in access to let users fills in the data then export them to xml and send back to the sender.
Now, what i did is put the xml+xsd (by the way he sent another file called .xsx extention which I don`t know what is it), in a folder then tried to import the xml into access i got error, which is unspecified error (can`t processing ..xml..~ )
Also, I don`t know the system of the third party and how he export this xml+xsd to me.
what i know only that i need to fill data in the same stucture of the xml he send , and give me back
Not sure, but here is a sample table from access exported to XML./XSD
It import fine back into Access without issue.

Ask your 3rd part person to compare the internal structure of the two files to the structure in his two files.
Then see if they can adjust their xml output system to more closely follow the format of my sample files...
YourTable.xml
YourTable.xsd
my problem is that I have no contact with the 3 party, it hard to ask changing there format.
Is it possible to fix the issue in the files mentioned in my Q?
There is no "One click" answer in Access, sorry...

You would have to write code to parse the XML file and format it the way that Access prefers...
perhaps there are tools to do this, but I am only an Access Expert, not really an expert in XML...


So lets see if an expert better at XML will chime in...

JeffCoachman
Oh, I understand, I just thought that access 2010 have the ability to import every xml been written around, (from what i know XML have a perminant rules (W3C XML Schema) , That`s why i thought the xml+xsd i mentioned here having wrong lines that need to be fixed before imported to access.
Yes, the issue was in reading the .xsd file
There were no indications in Access stating what the problem might be.
In looking at the two files, I do see some differences in the layout... This is what would probably need to be modified...
Remove the reference to the .xsd file:

<?xml version="1.0" encoding="UTF-8" ?>
<UnusualEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" REMOVED>
  <currentDate>2013-05-08</currentDate>
  <factorCode>11</factorCode>
  <report>

I did that, and Access imported it fine, and created 3 tables. Obviously, you don't need the word "REMOVED" in your XML - I put it there so you'd know what I took out.

If you need more control over the import process, the only way to handle that would be through the MSXML library. Here's a nice startup tutorial on that:

http://www.databasejournal.com/features/msaccess/article.php/3310901/Import-XML-Data-Into-Microsoft-Access.htm
thnx LSMConsulting, i did it and it works, but what about the related xsd i can`t import it , what should i change in the xsd to let it imported?
I'm not sure what you mean.

The .xsd file is really nothing more than the "schema" of an XML file. It defines the elements, element types, relationships, etc etc. You can't really import an .xsd file, nor would you want to do so.
Thanks for helping out here Scott...
I was hoping someone a bit stronger in XML would chime in...
;-)
Jeff
well, still have problem in understand the xml point.
I have attached the schema screenshot in from opening the file in excel .
If we look , we will see:
tableName: Branch , then there fields (phonenumber,branchcode,depositor etc..)
now the table branch is under "report" in the tree.
the problem if , if i make a tables in access , how can i export them to xml file with same structure (tree in the image attached)
untitled.bmp
btw, seems to run or check the xsd i should attached another file come with this xsd.
here is it
common.xsd
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
LSMConsulting, Bro, I have created table with relationship between them,
I could be able to export the table with with the childs table successfully by using:
right click table ->export ->xml file->then OK-> then go to "more option" , and in the data to export i just check of the table (main table and another 5 child tables.
it works .
the big problem i`m facing and i would be very glad you help me out in it is when i save this export and run in on click button in form :
DoCmd.RunSavedImportExport "exportsavedName"
it works and export the tableS to xml.
but it gives me only main table with one child under it, and then the other sub childs just jump under the main table .
how can i solve this problem, or maybe modify the hidden exportsavedName~?
I have also seek the net i found this:
Private Sub ExportRelTables()
   ' Purpose: Exports the Orders table as well as
   ' a number of related databases to an XML file.
   ' XSD and XSL files are also created.

   Dim objAD As AdditionalData

   ' Create the AdditionalData object.
   Set objAD = Application.CreateAdditionalData

   ' Add the related tables to the object.
   With objAD
      .Add "Order Details"
      objAD(Item:="Order Details").Add "Order Details Details"
      .Add "Customers"
      .Add "Shippers"
      .Add "Employees"
      .Add "Products"
      objAD(Item:="Products").Add "Product Details"
      objAD(Item:="Products")(Item:="Product Details").Add _
         "Product Details Details"
      .Add "Suppliers"
      .Add "Categories"
   End With

   ' Export the Orders table along with the addtional data.
   Application.ExportXml acExportTable, "Orders", _
       "C:\Orders.xml", "C:\OrdersSchema.xsd", _
       "C:\OrdersStyle.xsl", AdditionalData:= objAD
End Sub

may this help me out, and how to modify it ~?
I've never used those methods to move XML data out, so can't really comment.

With that said, did you try the method with your own tables? For example, it seems you just do this:

obj.Add "TableName"

If you need to add "sub tables", you do this:

objAD(Item:="Order Details").Add "Order Details Details"

In the line above, you're adding a table named "Order Details Details" as a "child" table of the "Order Details" table.

Try that, and report back with what you find.
thnx bro for reply,
I`ll be glad if you may have a look at this Q : ID28228077
It`s related to same problem, and there i have reach good result using another way . Maybe there you will have good idea. :}
LSMConsulting, I got error this the code upbove :

compile error:
Named argument not found


and have a highlight in "Item:="
 objAD(Item:="Order Details").Add "Order Details Details"
well I be able to fix the error by using:
 objAD.Item("Order Details").Add "Order Details Details"

but this doesn`t work for me :
objAD.Item("tablename")item("childTable").Add "sub-childTable"
which I need. I need the sub-childtable to be as a sub if childtable and the childtable to be the sub of the tablename