A simple groovy script follows that compares two strings to give you an idea of the things you can customise.
import org.custommonkey.xmlunit.XMLUnit;
def xml1 =
'''
<test><hello/><data>text</data><data2>text2</data2><cdata>cdatatext</cdata></test>
'''
def xml2 =
'''
<test>
<hello/>
<data>text</data>
<data2>
text2
</data2>
<cdata><![CDATA[cdatatext]]></cdata>
<!-- comment -->
</test>
'''
// most likely comparison you want
XMLUnit.setIgnoreWhitespace(true)
XMLUnit.setIgnoreComments(true)
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true)
XMLUnit.setNormalizeWhitespace(true)
System.out.println(XMLUnit.compareXML(xml1, xml2))
Here is a version that compares two files passed as arguments
import org.custommonkey.xmlunit.XMLUnit;
def xml1 = new FileReader(args[0])
def xml2 = new FileReader(args[1])
XMLUnit.setIgnoreWhitespace(true)
XMLUnit.setIgnoreComments(true)
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true)
XMLUnit.setNormalizeWhitespace(true)
System.out.println(XMLUnit.compareXML(xml1, xml2))