*I am using the DifferenceListener to ignore these differences:
publicclassMyDifferenceListenerimplementsDifferenceListener{privatestaticfinalint[]IGNORE_VALUES=newint[]{DifferenceConstants.CHILD_NODELIST_LENGTH_ID,DifferenceConstants.CHILD_NODELIST_SEQUENCE_ID,DifferenceConstants.ATTR_SEQUENCE_ID,DifferenceConstants.HAS_CHILD_NODES_ID};static{Arrays.sort(IGNORE_VALUES);}privatebooleanisIgnoredDifference(finalDifferencedifference){intdifferenceId=difference.getId();for(intelement:IGNORE_VALUES){if(differenceId==element){returntrue;}}returnfalse;}@OverridepublicintdifferenceFound(finalDifferencedifference){if(isIgnoredDifference(difference)){returnRETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;}else{returnRETURN_ACCEPT_DIFFERENCE;}}@OverridepublicvoidskippedComparison(finalNodenode,finalNodenode1){// TODO Auto-generated method stub}}
The ElementNameAndAttributeQualifier is giving me these results:
Try using this qualifier that compares XML nodes and attributes before comparing the text value. The RecursiveElementNameAndTextQualifier assumes nodes match if the node and text values match. In most cases you want to also only match if the node and and attributes also match before comparing the text of the node.
The two xmls I am trying to compare are:
I want the application to give me the following differences:
I have tried using
RecursiveElementNameAndTextQualifieras well as theElementNameAndAttributeQualifier. But I am not getting the desired results.My code is as follows:
The
ElementNameAndAttributeQualifieris giving me these results:Which
ElementQualifiershould I use or override any method to get the desired results?Try using this qualifier that compares XML nodes and attributes before comparing the text value. The RecursiveElementNameAndTextQualifier assumes nodes match if the node and text values match. In most cases you want to also only match if the node and and attributes also match before comparing the text of the node.