I am a beginner in C# and XML. I want to know how I can parse through XML files and combine many files into one file based on the nodes. All the XML files have the same format and the same kind of nodes.
Asked
Active
Viewed 46 times
-2
-
Please show code to document what you have attempted; even if it doesn't work. This will give us something to work with. – rfornal Jan 13 '15 at 14:25
-
This could be of some help, http://stackoverflow.com/questions/5195728/best-way-to-read-through-xml – Paulie Jan 13 '15 at 14:26
-
Here is the official documentation http://msdn.microsoft.com/en-us/library/b2s063f7(v=vs.71).aspx – Mahesh Jan 13 '15 at 14:27
1 Answers
0
It can be a bit advanced for you, but taking into account that all your XML files are structurally identical (and valid XML files) you can use xsd.exe tool to create class from one of the XML files and then use deserializer to load them one-by-bone from the file as class. Then you can use whatever you want and aggregate them the way you like. See the following link for instructions: https://stackoverflow.com/a/364410/1786034
When everything is in memory aggregated you can just use Linq-to-XML to generated the final file or serealize the object you've build in memory back to a single XML file.