aspose file tools*
The moose likes XML and Related Technologies and the fly likes Comparing 2 XML Files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Comparing 2 XML Files" Watch "Comparing 2 XML Files" New topic
Author

Comparing 2 XML Files

Dave Hewy
Ranch Hand

Joined: Aug 21, 2003
Posts: 93
I have a requirement to compare 2 XML files, say A and B, and to mark-up B to flag the differences. I think at this stage the structure will be the same, but am not certain.

So if an element has changed in B, then B would have an extra attribute added, something like changed="Y".

I need to do this programatically, has anyone had a similar experience that can point me at some info ?

TIA

Dave
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
Are these files small enough that both will fit in memory as DOMs?
I'm assuming that you want to ignore differences in formatting that a pure text comparison would find. For example - you want the two ways of writing an empty element to be considered identical.
<element></element> same as <element/>

A google search for "xml document equality" gets loads of hits since this problem has been bothering XML people for a long while.
Bill
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18675
    
    8

Another good set of search keywords is "xml diff".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Comparing 2 XML Files