0
<!------------------------File1--------------------------------->
Node id="123">
 <to>Name</to>
 <from>User</from>
<Boolean id>123</Boolean id>
</Node >
 <!------------------------File2--------------------------------->
<Node id="12369">
<to>Name</to>
<from>User</from>
<Boolean id>123</Boolean id>
 </Node >

I have to ignore the attribute:boolean id from Node up on comparing the files at specific node level.

I am using DiffBuilder

Diff diff = 
      DiffBuilder.compare(root).withTest(root2).checkForSimilar()
            .withNodeFilter(
                    node -> !(node.getNodeName().equals("Assoc_CIDB") || node.getNodeName().equals("Synoptics")))
            .withNodeMatcher(new DefaultNodeMatcher(es)).build();

Can someone suggest me a way how i can achieve the issues : 1.Ignore specific attributes on a specific node. 2.If the differences are at from attributes then i just compare and check to attributes details I can achieve this using XMLUnit 2.x Iam New to XMLUnit so someone please help me accordingly.

Thanks in advance.

Anu
  • 11
  • 4
  • I see following class got used.How to add attribute filter to diff?? .IgnoreNoteId implements Predicate { public boolean test(Attr attr) { return !("note".equals(attr.getOwnerElement().getNodeName()) && "id".equals(attr.getNodeName())); } } – Anu Oct 30 '18 at 16:34
  • Have you read the documentation https://www.xmlunit.org/api/java/master/org/xmlunit/builder/DiffBuilder.html#withAttributeFilter-org.xmlunit.util.Predicate- – mallikarjun Oct 31 '18 at 05:53
  • I got that.Thank u :-) Is it possible to get Similarities using Diff ?? – Anu Oct 31 '18 at 07:47

0 Answers0