开发者

Importing xml file and referencing an xsd file

开发者 https://www.devze.com 2023-03-08 18:47 出处:网络
I am trying to find a way to import an xml file, with an xsd that is a seperate file (not embedded in the xml).

I am trying to find a way to import an xml file, with an xsd that is a seperate file (not embedded in the xml).

 Application.ImportXML DataSource:=varResult, ImportOptions:=acAppendData

is the basic way I know how to import an xml file (where varResult is a variable being passed form a FilePicker routine). As far as I know there are three basic arguments you can use, and this has nothing to do with what I am trying to get at. If I was to import the xml file I have it would not c开发者_Go百科reate multiple records for one of the tables; rather those values would just overwrite the previous record.

I know how to just go through the nodes, with nodelist, grab the values manually, loop through that, build temp tables, and migrate the data from the temps to the proTables, but that is alot of coding, just to make up for the fact that I just don't know how to programmatically reference an xsd file, in order to use the generic import command.


AFAIK there is no ImportXML option to reference a separate xsd file. But since you know the names and locations of your xml and xsd files, perhaps you could merge them and feed to merged file to ImportXML.

I haven't tried this myself, but suspect you could do the merge in 2 ways:

  1. add the xsd tag lines to the xml file's root
  2. change the xml dataroot to include xsi:noNamespaceSchemaLocation="YourXsdFile.xsd"

Both of those approaches seem kind of kludgey. The question is ... can you do it with significantly less code than it takes to open the xml doc and then parse and store the values?


I don't think the ImportXML method is robust enough to do what you want to do. If you're already using the AppendData option and it isn't appending data to your specifications then I believe you'll have to figure out a different way of doing it.

In my own experiments ExportXML, I think the data structure definition is included in the XML file. I think Import XML is expecting the same and gives you no other option.

You've indicated that you already know how to load the XML file and iterate through it in order to import your data. My research shows that there is no simple way to import an XML file into an existing table if the ImportXML file doesn't do what you need it to do. You could possibly simplify the manual import by loading the XML file as an ADO Recordset.

Take a look at this related link:
http://bytes.com/topic/access/answers/504646-append-ado-recordset-table

0

精彩评论

暂无评论...
验证码 换一张
取 消