I've got two XML files and I want to compare in a C# application. I am using XDocument and I want to load both XML files (which have static filenames and directories) and search and append an entry based on matching values. One of my XML files contains the following structure as shown below:
<Code>0000890</Code>
<Device_Name>Device1</Device_Name>
<Time>11:06:18.836 </Time> </body>
The second XML file has a structure like this:
<ID>0000890</ID>
<FirstName>John</FirstName>
<LastName>Doe</LastName> </body>
I want to read both files and match records where the ID and Code are the same but also append the first XML files with the additional details from the second XML file. So in matching cases id end up with:
<ID>0000890</ID>
<FirstName>John</FirstName>
<LastName>Doe</LastName>
<Device_Name>Device1</Device_Name>
<Time>11:06:18.836 </Time> </body>
Should i use a foreach loop and step through all the entries or what is the best approach? Any help would be greatly appreciated. Thank you