I’m working on a project that includes comparing XML files and I need a source code on Java to compare XML fragments.
I’m using ExamXML from http://www.a7soft.com to compare XML files but I need the Java source code.

11 Years
Discussion Span
Last Post by orko

I faced a similar problem in one of my projects and hence wrote my own comparator.
This comparator can be invoked via web, using a simple java code. You can view more details at http://www.cityhaat.com/adAction.do?dispatchMethod=viewAd&adId=291 about how to use this comparator from your code. The sample code is available at http://cityhaat.com/xmlComp/ClientUtil.zip

The comparator that I wrote gives you the flexibility to configure how to identify a node from a set of repeated nodes and is able to compare them successfully if they occur in any order. You can send a message via http://www.cityhaat.com/adAction.do?dispatchMethod=viewAd&adId=291 this link if you need customizations for your comparisons. Its FREE.


I would use the API available with java, which no doubt there must be for xml. It would be more reliable than any custom built programs.


for similar project I used DOM. It is not very difficult to do once you give a try. Besides, xml diff tools may not be very effective as it doesn't know how flexible you want to be. So instead of looking for others code, you better consider reading some introductory DOM parsing, get the nodes information, compare each other, and get your own diff tool. One example for starting your reading can be: http://www.onjava.com/pub/a/onjava/2001/02/08/dom.html

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.