title: Comparing two xml files in Objective-C
body: <p>I have two xml files (a.xml and b.xml) in my file system (iPhone). Now I want to know if these files contain exactly the same data. Most of the time, this comparison would be true, because b.xml is the result of a copyItemAtPath: operation. Unless it is overwritten by newer information.
  What would be the most efficient way to compare these files?</p>
  
  <ol>
  <li>I could read the contents of the files as strings and then compare the strings</li>
  <li>I could parse the files and compare some key elements</li>
  <li>I guess there is a very blunt way, that doesn't need to interpret the file, but allows me to compare on a lower level.</li>
  </ol>
  
  <p>Any suggestion is very welcome.</p>
  
  <p>Thanks ahead</p>
  
  <p>Sjakelien</p>
  
  <p>Update:</p>
  
  <p>I ended up doing this:</p>
  
  <pre><code>oldData = [NSData dataWithContentsOfFile:PathToAXML];
  newData = [NSData dataWithContentsOfFile:PathToBXML];
  </code></pre>
  
  <p>and then compare it with:</p>
  
  <pre><code>[newData isEqualToData:oldData];
  </code></pre>
  
  <p>The question is still: is that more efficient than:</p>
  
  <pre><code>oldData = [NSString dataWithContentsOfFile:PathToAXML];
  newData = [NSString dataWithContentsOfFile:PathToBXML];
  
  [newData isEqualToString:oldData];
  </code></pre>