File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes compare the two xml files attributes, elements & sub elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "compare the two xml files attributes, elements & sub elements " Watch "compare the two xml files attributes, elements & sub elements " New topic
Author

compare the two xml files attributes, elements & sub elements

ashok ks
Ranch Hand

Joined: Oct 31, 2003
Posts: 55
How can i compare two xml files attributes, elements & sub elements ?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
What exactly do you mean by "comparing"?
Is it enough to know whether two documents are identical, similar or different, or do you need to know *what* is different between two documents?
The former requirement would be easy to satisfy with XMLUnit.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
ashok ks
Ranch Hand

Joined: Oct 31, 2003
Posts: 55
I would like to know about *what* is different between two documents details also.
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by ashok ks:
I would like to know about *what* is different between two documents details also.

Just wondering why ??
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
In fact, XMLUnit provides a class named DetailedDiff which can list detailed differences between two documents.
Here's some sample code:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compare the two xml files attributes, elements & sub elements
 
Similar Threads
converting xml to xsl
reading xml file in string format
Attributes are getting sorted when I use Xalan.jar along with jaxp.jar in classpath.
compare two xml files thru .java class using SAX / DOM parser
how to compare two xml files?