title: How to diff-compare two xml files using java
body: <p>I have two xml files that I want to compare:</p>
  
  <p><strong>old.xml:</strong></p>
  
  <pre><code>&lt;EMPLOYEES&gt;
    &lt;employee&gt;
      &lt;id&gt;102&lt;/id&gt;
      &lt;name&gt;Fran&lt;/name&gt;
      &lt;department&gt;  THIS IS COMPUTER DEPARTMENT  &lt;/department&gt;
    &lt;/employee&gt; 
    &lt;employee&gt;
      &lt;id&gt;105&lt;/id&gt;
      &lt;name&gt;Matthew&lt;/name&gt;
      &lt;department&gt; THIS IS SCIENCE AND TECHNOLOGY &lt;/department&gt;
    &lt;/employee&gt; 
  &lt;/EMPLOYEES&gt;
  </code></pre>
  
  <p><strong>new.xml :</strong></p>
  
  <pre><code>&lt;EMPLOYEES&gt;
    &lt;employee&gt;
      &lt;id&gt;105&lt;/id&gt;
      &lt;name&gt;Matthew&lt;/name&gt;
      &lt;department&gt;  THIS IS SCIENCE AND TECHNOLOGY **Modified *** &lt;/department&gt;
    &lt;/employee&gt; 
    &lt;employee&gt;
      &lt;id&gt;106&lt;/id&gt;
      &lt;name&gt;xyz&lt;/name&gt;
      &lt;department&gt; THIS IS SCIENCE AND TECHNOLOGY &lt;/department&gt;
    &lt;/employee&gt;
    &lt;employee&gt;
      &lt;id&gt;107&lt;/id&gt;
      &lt;name&gt;Francis&lt;/name&gt;
      &lt;department&gt;  THIS IS XYZ  &lt;/department&gt;
    &lt;/employee&gt;
  &lt;/EMPLOYEES&gt;
  </code></pre>
  
  <p>I want to compare the two files and return which records were added, deleted, or updated.  <code>old.xml</code> contains 2 <code>&lt;employee&gt;</code> records and <code>new.xml</code> contains 3 <code>&lt;employee&gt;</code> records. </p>
  
  <p><strong>I'd like the results to be like this:</strong></p>
  
  <p><strong>Added records</strong>
  2 : ex:- employee.id=106  and employee.id=107</p>
  
  <p><strong>Deleted records</strong>
  1 : ex:-  employee.id=102</p>
  
  <p><strong>Updated records</strong> 
  1: ex:- employee.id=105 updated with  ---- </p>
  
  <p>What is the best way to diff these two XML files to get these results?</p>