如何读取从Access导出到DataSet或DataTable的XML + XSD文件 [英] How can I read XML+XSD files exported from Access into DataSet or DataTable

查看:111
本文介绍了如何读取从Access导出到DataSet或DataTable的XML + XSD文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将xml数据读入DataSet。如果我导出数据集并再次回读,这可以正常工作。


但是如果我在Access中导出表并生成XML + XSD文件,则DataSet.ReadXML无法加载这些文件。 / p>

是否有办公应用程序生成的XML文件的阅读器,以便我可以使用阅读器将数据读入数据集。


如果没有, c#.net环境中还有哪些其他方法可以实现此目的?

解决方案

首先读取架构(xsd)文件时会发生什么?使用ReadXmlSchema然后使用ReadXml的XML文件?您是否收到错误或为什么说"无法加载"?我只是想知道会发生什么,我不熟悉Access导出格式
以及它是否与DataSet.ReadXmlSchema / ReadXml方法兼容。


当然是DataSet.ReadXml不是用于解析XML文档的主要通用.NET API,即用于低级解析的XmlReader和用于.NET 2.0和3.0的XmlDocument或XPathDocument以及用于更高级别的.NET 3.5和4.0中的XDocument,因此如果ReadXml失败,则为
当然可以处理任何XML文档。然后,您可以编写自己的代码以转换为ReadXml可以处理的格式,或者您可以使用自己的代码直接填充DataSet。


I am trying to read xml data into a DataSet. This works fine if I export a dataset and read back again.

But if I export a table in Access and generate XML + XSD files, these files cannot be loaded by DataSet.ReadXML.

Is there a reader for XML files generated by office applications so that I can use the reader to read data into a data set.

If not, what other methods do exists in c# .net environment to accomplish this?

解决方案

What happens when you read the schema (xsd) file first with ReadXmlSchema and then the XML file with ReadXml? Do you get an error or why do you say "cannot be loaded"? I am just asking what happens, I am not familiar with the Access export format and whether it is compatible with the DataSet.ReadXmlSchema/ReadXml methods.

Of course DataSet.ReadXml is not the primary general .NET API to parse XML documents, that is XmlReader for low level parsing and XmlDocument or XPathDocument in .NET 2.0 and 3.0 and XDocument in .NET 3.5 and 4.0 for a higher level so if ReadXml fails you can certainly process any XML document that way. You could then write your own code to transform into a format ReadXml can deal with or you could directly populate a DataSet with your own code.


这篇关于如何读取从Access导出到DataSet或DataTable的XML + XSD文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆