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.

Do not expect anybody give you such code for free, we may guide you in developing such application but major work is up to you

PS: It will be very nice if you make up your mind which programming language you wish to use, plus read rules about posting, specialy section that talks about double posting


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.

Member Avatar for iamthwee

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.