Good java library for comparing xml files for unit testing?

I am looking for a good java library for comparing xml files in unit tests. Currenly we use a simple string comparison, but this requires the xml file to print the same way (at the same time on 1 line).

I found the following on the net: http://xmlunit.sourceforge.net/ . But I look old (latest version since September 2009). Does anyone know a newer library or is it still in use?

thank

+5
source share
1 answer

xml-matchers is what you are looking for. The library seems to be actively maintained:

assertThat(the(xml), isEquivalentTo(the(xml2)));

Also try jcabi-matchers :

assertThat(XhtmlMatchers.the(xml), XhtmlMatchers.hasXPath("/html/body"))
+3
source

All Articles