Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For fun, a general solution to grega g's reading of the problem. To illustrate my objection to this approach, I've introduced a "correct" entry for 'PowerShell in Action'.</p> <pre><code>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;book id='20508' image='C05' name='PowerShell in Action'/&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;book id='20508' image='C05' name='PowerShell in Action'/&gt; &lt;/Books&gt;"; XDocument xml1 = XDocument.Parse(s1); XDocument xml2 = XDocument.Parse(s2); var res = from b1 in xml1.Descendants("book") from b2 in xml2.Descendants("book") let issues = from a1 in b1.Attributes() join a2 in b2.Attributes() on a1.Name equals a2.Name select new { Name = a1.Name, Value1 = a1.Value, Value2 = a2.Value } where issues.Any(i =&gt; i.Value1 == i.Value2) from issue in issues where issue.Value1 != issue.Value2 select issue; </code></pre> <p>Which reports the following:</p> <pre><code>{ Name = image, Value1 = C01, Value2 = C011 } { Name = name, Value1 = ASP.NET, Value2 = ASP.NET 2.0 } { Name = id, Value1 = 20507, Value2 = 20508 } { Name = image, Value1 = C05, Value2 = C04 } { Name = name, Value1 = PowerShell in Action, Value2 = Architecting Applications } </code></pre> <p>Note that the last two entries are the "conflict" between the 20508 typo and the otherwise correct 20508 entry.</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