如何将几个xml文件合并到一个文件中? [英] How to merge several xml files into a single file ?
本文介绍了如何将几个xml文件合并到一个文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将多个xml文件合并到一个xml文件中?...几个文件就10个文件而言。我需要将这些文件连接成一个文件。我尝试使用Xml文档,但它需要大量内存,当这些文件放入一个文件时,它有2 GB的内存,这是不合适的,所以我需要知道是否有其他选项?...任何人都可以告诉我关于XStreaming元素>
Hi,
How do I merge several xml files into a single xml file?...Several files in the sense about 10 files. I need to concatenate these files into one single file. I tried with Xml document but it takes a lot of memory and when these files are into one single file it has a memory of 2 gb which is inappropriate so I need to know whether there are other options?...Can any one tell me about XStreaming element>
推荐答案
ADO .NET DataSet将帮助您。
请看这里:
https://support.microsoft.com/en-us/kb/311530 [ ^ ]
例如C#WPF
ADO .NET DataSet will help you.
Please have a look here:
https://support.microsoft.com/en-us/kb/311530[^]
e.g. C# WPF
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
ofd.Filter = "XML files (*.xml) |*.xml";
bool? result = ofd.ShowDialog();
if(result == true)
{
DataSet dsAll = new DataSet();
foreach (string fileName in ofd.FileNames)
{
DataSet dsTemp = new DataSet();
dsTemp.ReadXml(fileName);
dsAll.Merge(dsTemp);
}
string directoryName = Path.GetDirectoryName(ofd.FileNames.First());
string exportfileName = Path.Combine(directoryName, "All.xml");
dsAll.WriteXml(exportfileName);
}
这篇关于如何将几个xml文件合并到一个文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文