Amit Sharma

Amit Sharma

  • NA
  • 23
  • 4.8k

Merge multiple xml files in one file

Oct 19 2020 3:18 AM
Hi friend,
 
I tried this but I am getting an error (Error: 'XDocument' does not contain a definition for 'Dump' and no extension method 'Dump' accepting a first argument of type 'XDocument'could be found ) on masterfile.Dump();
 
Can anyone help regarding this error ???
 
MY CODE:-
  1. protected void Button3Merge_Click(object sender, EventArgs e)  
  2. {  
  3. var downloadfolder = @"E:\Desktop\XeroConnectData\Schema\All_22files\"// download folder path  
  4. string[] files = Directory.GetFiles(downloadfolder);  
  5. var masterfile = new XDocument();  
  6. XElement newDocument = new XElement("Invoice");  
  7. masterfile.Add(newDocument);  
  8. foreach (var file in files)  
  9. {  
  10. Console.WriteLine("--------------------------------------------------");  
  11. Console.WriteLine(file);  
  12. Console.WriteLine("--------------------------------------------------");  
  13. XDocument xdoc = XDocument.Load(file);  
  14. masterfile.Root.Add(xdoc.Descendants("Invoice")); // root note  
  15. }  
  16. masterfile.Dump();  
  17. masterfile.Save(@"E:\Desktop\XeroConnectData\merged_.xml");  
  18. }  

Answers (1)