title: Is there an AssertEquals for testing XML files?
body: <p>I have frequent need to test that XML files are correct and need a way of testing that 2 XML strings (or documents) are identical, such as:</p>
  
  <pre><code>XMLAssert.assertEquals(String xmlExpected, String xmlActual);
  </code></pre>
  
  <p>In addition it would be useful to show where the xml documents differed. </p>
  
  <p>This should be restricted to documents with standalone="yes" (i.e. the DTD or schema - if any - is not significant). This means that there are no default values, and attribute types are irrelevant. Adjacent text PCDATA nodes should be normalised (concatenated). </p>
  
  <p>Note that this cannot be done simply by lexical comparison</p>
  
  <pre><code>Assert.assertEquals(xmlExpected, xmlActual);
  </code></pre>
  
  <p>as there are indefinitely many ways of rendering the same XML infoset. The comparison should take account of namespaces on elements and attributes (but not attribute values - which are not part of the spec). </p>
  
  <p>One way to do this might involve canonicalising both documents. Alternatively an XMLDiff could be used.</p>
  
  <p>I could not find anything so wrote my own a few years ago. </p>
  
  <p>[I also have a particular need to compare floating point values though this must be a hack since the data type of CDATA or PCDATA  can only be guessed and is out of immediate scope for the question.]</p>
  
  <p><strong>NOTE:</strong> There will probably need to be a specific solution for each language. I am particularly interested in Java and C#</p>