I'am using XMLUnit to compare two XML files(the only difference is in version):
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.4</version>
</dependency>
and:
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.5</version>
</dependency>
with a code which you can see below:
XMLUnit.setIgnoreWhitespace(true);
DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(getGoodXML(), getWrongXML()));
List<Difference> allDiifferences= diff.getAllDifferences();
for(Difference in : allDiifferences){
System.out.println("VALUE1("+in.getControlNodeDetail().getValue()+") VALUE2("+in.getTestNodeDetail().getValue()+")");
}
Right now I get all differences between those two XML files. My goal is to get the whole path to those different elements. I should be able to get something like this:
/dependency/version/ VALUE1(1.4) VALUE2(1.5)
I suppose there is a better way to get the whole path than using something like this:
Node previousNode = in.getControlNodeDetail().getNode.getParentNode()
I am looking for a method which get all previous node names. Any hints?