Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is the solution:</p> <pre><code>//sanitised xmls: string s1 = @"&lt;Books&gt; &lt;book id='20504' image='C01' name='C# in Depth'/&gt; &lt;book id='20505' image='C02' name='ASP.NET'/&gt; &lt;book id='20506' image='C03' name='LINQ in Action '/&gt; &lt;book id='20507' image='C04' name='Architecting Applications'/&gt; &lt;/Books&gt;"; string s2 = @"&lt;Books&gt; &lt;book id='20504' image='C011' name='C# in Depth'/&gt; &lt;book id='20505' image='C02' name='ASP.NET 2.0'/&gt; &lt;book id='20506' image='C03' name='LINQ in Action '/&gt; &lt;book id='20508' image='C04' name='Architecting Applications'/&gt; &lt;/Books&gt;"; XDocument xml1 = XDocument.Parse(s1); XDocument xml2 = XDocument.Parse(s2); //get cartesian product (i think) var result1 = from xmlBooks1 in xml1.Descendants("book") from xmlBooks2 in xml2.Descendants("book") select new { book1 = new { id=xmlBooks1.Attribute("id").Value, image=xmlBooks1.Attribute("image").Value, name=xmlBooks1.Attribute("name").Value }, book2 = new { id=xmlBooks2.Attribute("id").Value, image=xmlBooks2.Attribute("image").Value, name=xmlBooks2.Attribute("name").Value } }; //get every record that has at least one attribute the same, but not all var result2 = from i in result1 where (i.book1.id == i.book2.id || i.book1.image == i.book2.image || i.book1.name == i.book2.name) &amp;&amp; !(i.book1.id == i.book2.id &amp;&amp; i.book1.image == i.book2.image &amp;&amp; i.book1.name == i.book2.name) select i; foreach (var aa in result2) { //you do the output :D } </code></pre> <p>Both linq statements probably could be merged, but I leave that as an exercise for you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload