xmlunit icon indicating copy to clipboard operation
xmlunit copied to clipboard

Possible to Ignore element by name using XmlAssert of the xmlunit-assertj3 module?

Open bensullivan-ag opened this issue 4 years ago • 1 comments

Hi

Is it possible to specify elements to ignore when comparing xml using assertj 3?

assertThat(createTestDocument())
.and(Input.fromFile("test-data/good.xml"))
.ignoringElements("foo", "bar")
.areIdentical();

Thanks

Ben

bensullivan-ag avatar Apr 17 '22 22:04 bensullivan-ag

withNodeFilter is what you are looking for. Something like

.withNodeFilter(n -> !(n instanceof Element && ("foo".equals(n.getLocalName()) || "foo".equals(n.getNodeName())))

bodewig avatar Apr 20 '22 16:04 bodewig