Comparing two XML files with IEnumerable.Except()

jjaz

New Member
With the following code:\[code\] XDocument aDoc = XDocument.Load(fileA); XDocument bDoc = XDocument.Load(fileB); var commonfromA = aDoc.Descendants("Project").Except(bDoc.Descendants("Project")); \[/code\]I compare the following XML:aDoc.xml\[code\]<Employees> <Project ID="1" Name="Project1"/> <Project ID="2" Name="Project2"/></Employees>\[/code\]bDoc.xml\[code\]<Employees> <Project ID="1" Name="Project1"/> <Project ID="3" Name="Project3"/></Employees> \[/code\]When I execute the code I obtain \[code\]<Project ID="1" Name="Project1"/><Project ID="2" Name="Project2"/>\[/code\]Rather than\[code\]<Project ID="2" Name="Project2"/> **Which is the elements that are in A but not in B**\[/code\]Thank you in advance.
 
Back
Top