File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML file comparison

 
ARS Kumar
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
Is there any tool ( in Java API ) which I can use in my application to compare two XML files ?
Thanks
ARS Kumar.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar,
Since XML files are text-based, you can use any freely available file comparison tools to compare XML files. Or even better, you can write one yourself.
Many implementations of DOM( Sun, IBM, Oracle etc ) also have helper methods that return the String representation of the XML document. If you just want to compare two XML files to findout if they are same( and not worry about how they differ if they differ, ) then you can simply use equals() method on the returned string objects. Voila!!
Hope that helps
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
ARS Kumar
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ajith
What you said is what I end up doing. I don't see any single method that returns a String in xercers parser. So I wrote a small method to just read in the XML file and created a String out of it. Then I did the the string comparison like you mentioned with a small change. In this specific case I need to eliminate one tag before comparing.
http://www.deltaxml.com/index.html is the tool which I found close to what I was looking for. Because while comparing the two XML files actually I need to know which are tags that changed. I am in the process of evaluating the same. The free version is only available as command line.
Thanks a lot for your help


------------------
Regards
ARS Kumar
Sun Certified Java 2 Programmer.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic