读取xml文件并导入数据集中所有数据的最快方法 [英] Fastest way to read xml file and import all data in dataset

查看:96
本文介绍了读取xml文件并导入数据集中所有数据的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个2 GB的xml文件。

我可以使用.Net的feature datase.loadxml()方法来读取这个文件。但它非常慢。



我的问题:是否还有其他方法可以读取xml文件并将其加载到数据集中。我需要在数据集中加载它



请帮助!

I have a 2 GB xml file.
I can use the .Net's feature dataset.loadxml() method to read this file. But it's very much slow.

My question : is there any other way to read xml file and load it to a dataset. I need to load this in a dataset

Please help!

推荐答案

对于大型xml文件,加载整个xml将是缓慢且低效的,这导致性能不佳。这是CP本身的一篇文章,它解决了这个问题:



http://www.codeproject.com/Articles/156982/How-to-Open-Large-XML-files-without-Loading- -XM.aspx [ ^ ]
For large xml files, loading the whole xml will be slow and inefficient which results in poor performance. Here is an article in CP itself which addressed this issue:

http://www.codeproject.com/Articles/156982/How-to-Open-Large-XML-files-without-Loading-the-XM.aspx[^]


请检查以下链接



在C#中使用XmlReader读取Xml [ ^ ]
Please check following link

Reading Xml with XmlReader in C#[^]


As一旦你定义了XML元素中使用的XML命名空间,就可以轻松导入它 - 没问题。



你需要让你的XML看起来像这样: br />


As soon as you define your XML namespace used in the XML elements, you can easily import this - no problem.

You need to have your XML look something like this:

<Catalog xmlns:dt="some-xml-namespace-here">
 <Rec>
   <ITEM dt:dt="string"/>
   <QTY dt:dt="string">1</QTY>
   <SUB dt:dt="string">1</SUB>
   <CATALOG dt:dt="string">ABC123</CATALOG>
  </Rec>
  .....
 </Catalog>



执行此操作后,您的两行代码就像魅力一样,数据导入,没问题(进入5个表格)在数据集内。


After I do this, your two lines of code work like a charm and the data gets imported, no problem (into 5 tables inside the Dataset.


这篇关于读取xml文件并导入数据集中所有数据的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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