Of course, you have a XML Unit if you want to compare two XML and you could do it character by character.
XML Unit
Edited:
You have to download de XMLUnit JAR from here XML Sourceforge and then its easy, like JUnit, add to your classpath (by Eclipse / NetBeans / so on ...) and then you write a Test, like JUnit but extends from XMLTestCase, like this one:
import org.custommonkey.xmlunit.*;
public class XMLTesting extends XMLTestCase {
public void testForEquality() throws Exception {
String myControlXML = "<msg><uuid>0x00435A8C</uuid></msg>";
String myTestXML = "<msg><localId>2376</localId></msg>";
assertXMLEqual("comparing test xml to control xml", myControlXML, myTestXML);
assertXMLNotEqual("test xml not similar to control xml", myControlXML, myTestXML);
}
public void testIdentical() throws Exception {
String myControlXML = "<struct><int>3</int><boolean>false</boolean></struct>";
String myTestXML = "<struct><boolean>false</boolean><int>3</int></struct>";
Diff myDiff = new Diff(myControlXML, myTestXML);
assertTrue("pieces of XML are similar " + myDiff, myDiff.similar());
assertTrue("but are they identical? " + myDiff, myDiff.identical());
}
public void testAllDifferences() throws Exception {
String myControlXML = "<news><item id=\"1\">War</item>"
+ "<item id=\"2\">Plague</item><item id=\"3\">Famine</item></news>";
String myTestXML = "<news><item id=\"1\">Peace</item>"
+ "<item id=\"2\">Health</item><item id=\"3\">Plenty</item></news>";
DetailedDiff myDiff = new DetailedDiff(compareXML(myControlXML, myTestXML));
List allDifferences = myDiff.getAllDifferences();
assertEquals(myDiff.toString(), 0, allDifferences.size());
}
So you can see the easy way to compare two XML