This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 12761
    
    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: 18541
    
    8

Another good set of search keywords is "xml diff".
 
wood burning stoves
 
subject: Comparing 2 XML Files
 
Similar Threads
What WS should I use?
Strange question in mockup exam
how to modify the Symbolic link file.
Xml on netscape
XML related nightmares