Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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>
Posted
Comments
Maciej Los 22-Apr-15 12:20pm    
What have you done till now?
We can't read in your mind or direct from your screen. Please, be more specific and provide more details. Sample data would be helpful.

1 solution

ADO .NET DataSet will help you.
Please have a look here:
https://support.microsoft.com/en-us/kb/311530[^]

e.g. C# WPF
C#
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);
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900