Reputation: 644
I have two xmls in string format. Need to compare both of them by skipping few nodes. In the result only difference of node and corresponding values are required.
Suppose I have the following two xmls :
Message -1
<block4>
<tag>
<name>35B</name>
<value>/GB/B0W1VM9</value>
</tag>
</block4>
Message - 2
<block4>
<tag>
<name>35B</name>
<value>/US/999999999
NOT AVAILABLE AT PRESENT</value>
</tag>
</block4>
I am using XMLUnit but I want to find the difference from few blocks and want to skip few nodes having specific values. like in <tag>
value being : :PREV should be skipped.
Note : In the end want to print the result in excel.
Used the following code but not useful : https://stackoverflow.com/a/16471601/3493471
Upvotes: 0
Views: 901
Reputation:
Using XMLUnit 2.x you can use a NodeFilter
and suppress the nodes you want to skip. Something like
DiffBuilder b = DiffBuilder.compare(some-input)
.withTest(some-test)
.withNodeFilter(n -> !":PREV".equals(n.getTextContent()))
...
Upvotes: 0
Reputation: 24444
I think you can still use XMLUnit for that job, but you can't use the default settings. Instead, you may want to implement a custom DifferenceEvaluator
that ignores certain attributes or nodes.
See XMLUnit DifferenceEvaluator for details and examples.
Upvotes: 1