I have a code in java comparing 2 xml files using XMLUnit. It is highlighting the differences for a extra space in one of the lines which I wish to ignore. How can I achieve this.
Below are the settings used.
XMLUnit.setCompareUnmatched(true);
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setNormalize(true);
For Example: xml1:
<metadata><div><p>This is a test</p></div></metadata>
xml2:
<metadata><div><p>This is a test</p> </div></metadata>
The space between </p> and </div> tags is highlighted in above example.
The space after the
ptag is a text node by itself so it might not be possible to remove or ignore it by configuration.Getting each text node:
From the normalize-space() docs
From setIgnoreWhitespace(boolean ignore) XMLUnit docs
Also on same docs