title: Compare two xml files and display difference
body: <p>I am trying to compare two xml files and display the differences, if found.</p>
  
  <p>At the moment I am using <a href="https://msdn.microsoft.com/en-gb/library/aa302294.aspx" rel="nofollow">XML Diff</a> to find the difference. </p>
  
  <p>The method use</p>
  
  <pre><code> private bool CheckDifferences(string originalFile, string newFile, ref string difference)
      {
         var diff = new XmlDiff
         {
             IgnoreComments = true,
             IgnorePI = true,
             IgnoreWhitespace = true,
             Algorithm = XmlDiffAlgorithm.Precise
         };
  
          var sw = new StringWriter();
          var writer = new XmlTextWriter(sw);
          writer.Formatting = Formatting.Indented;
  
          var originalReader = new XmlTextReader(new StringReader(originalFile));
          var modifiedReader = new XmlTextReader(new StringReader(newFile));
          var status = diff.Compare(originalReader, modifiedReader, writer);
  
          difference = sw.ToString();
          writer.Close();
          originalReader.Close();
          modifiedReader.Close();
  
          return status;
      }
  </code></pre>
  
  <p>But <code>difference</code> will contains only the change, not what exactly changed.</p>
  
  <p>For example what I am trying to achieve is</p>
  
  <p><strong>xml1</strong> - Original File</p>
  
  <pre><code>&lt;catalog&gt;
     &lt;book id="bk11"&gt;
        &lt;author&gt;AuthorName1&lt;/author&gt;
     &lt;/book&gt;
  &lt;/catalog&gt; 
  </code></pre>
  
  <p><strong>xml2</strong> - New File</p>
  
  <pre><code>&lt;catalog&gt;
     &lt;book id="bk11"&gt;
        &lt;author&gt;AuthorName2&lt;/author&gt;
     &lt;/book&gt;
  &lt;/catalog&gt; 
  </code></pre>
  
  <p><strong><em>So I would like to display that author is changed to AuthorName2 etc...</em></strong></p>
  
  <p>The xml file structure is unknown, but both files will have the same structure.</p>
  
  <p>Also looked at the <a href="https://msdn.microsoft.com/en-us/library/system.xml.linq.xnode.deepequals%28v=vs.110%29.aspx" rel="nofollow">XNode.DeepEquals</a>, but it also return whether is there any difference or not. But not what the difference is.</p>
  
  <p>Any help is appreciate </p>