代码如下:
XDocument aDoc = XDocument.Load(fileA);
XDocument bDoc = XDocument.Load(fileB);
var commonfromA = aDoc.Descendants("Project").Except(bDoc.Descendants("Project"));
我比较了以下XML:
a Doc.xml 医生
<Employees>
<Project ID="1" Name="Project1"/>
<Project ID="2" Name="Project2"/>
</Employees>
b. xml 医生
<Employees>
<Project ID="1" Name="Project1"/>
<Project ID="3" Name="Project3"/>
</Employees>
当我执行我得到的密码
<Project ID="1" Name="Project1"/>
<Project ID="2" Name="Project2"/>
而不是
<Project ID="2" Name="Project2"/> **Which is the elements that are in A but not in B**
提前感谢您