Hi @Stace Clark ,
As far as I think,you could find the node "Destination". And then you need to join these two xml files to select name equals ConnectorName.Just like this:
var xml1 = XDocument.Load(@"C:\Users\yijings\source\repos\Webtest1\ConsoleApp5\XMLFile1.xml");
var xml2 = XDocument.Load(@"C:\Users\yijings\source\repos\Webtest1\ConsoleApp5\XMLFile2.xml");
var result = from e1 in xml1.Descendants().Elements("Destination")
join e2 in xml2.Descendants().Elements("Destination")
on e1.Element("Name").Value equals e2.Element("ConnectorName").Value
select new XElement("Destination", new object[] { e1.Element("DestinationID"),
e1.Element("MirthChannelID"),
e1.Element("MirthDestinationNumber"),
e1.Element("Name"),
e1.Element("Type"),
e1.Element("Active"),
e1.Element("DestinationReference"),
e1.Element("QueuingEnabled"),
e2.Element("MessageStatuses")
});
string file3 = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<Destination>" +
"</Destination>";
StringReader reader = new StringReader(file3);
XDocument newXDoc = XDocument.Load(reader);
newXDoc.Descendants("Destination").Last().Add(result);
Best regards,
Yijing Sun
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.