参见英文答案 >
exporting multiple access tables to single XML2个
我需要从Access创建一个XML文件.它必须具有关系节点类型格式.
我需要从Access创建一个XML文件.它必须具有关系节点类型格式.
例如:
<Item> <description></description> <colors> <blue> <green> </colors> </item>
项目的数据在表格中.颜色在另一个.我有参考ID,所以我可以加入它们.
如何才能做到这一点.我已经看了一遍,看看如何导出表,但不是嵌套类型的文件.
下面是我用于查询数据然后将结果导出到平面文件的示例.我已根据您的需要进行了调整.
原文链接:https://www.f2er.com/xml/452467.htmlOn Error GoTo Err_My_Click Dim rs As DAO.Recordset Set rs = CurrentDb.OpenRecordset("SELECT * FROM MyTable",dbOpenDynaset) If (rs.RecordCount <> 0) Then rs.MoveFirst Open "C:\Export\XML__MyFile.xml" For Output As #1 Do While rs.EOF = False TempExportCount = TempExportCount + 1 Print #1,"<Item>" Print #1," <description>" & rs.Fields("[Description]").value & "</description>" Print #1,"</Item>" rs.MoveNext Loop End If Exit_My_Click: On Error Resume Next rs.Close Set rs = Nothing Close 1# Exit Sub Err_My_Click: If (Err.Number = 76) Then MsgBox ("The program could not save the txt file." & vbNewLine & vbNewLine & _ "Make sure you have the following folder created: C:\Export\") Else MsgBox (Err.Description) End If Resume Exit_My_Click