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 compare two XML files using DOM parser 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 "compare two XML files using DOM parser " Watch "compare two XML files using DOM parser " New topic
Author

compare two XML files using DOM parser

Divya Gehlot
Ranch Hand

Joined: Sep 10, 2006
Posts: 243
Hi,
I need to compare two XML files in which second XML file has some slight modifications and I need to compare that particular node. Can any one help me by providing tutorials or any API( if its available).
As I am new in XML parsing.
for example-
First XML file
Second XML file--

like that some more nodes are there as I have to check names and then check enable_status and visisbility
How can I do that. Please help me
Thanks in advance.


SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
Craig Bayley
Ranch Hand

Joined: Sep 27, 2007
Posts: 46
Hava a look at xmlunit....You can use that to perform a diff.
Alternatively, marshall the xml into java objects and do direct comparison that way.
Divya Gehlot
Ranch Hand

Joined: Sep 10, 2006
Posts: 243
Hi,
As I am new to XML parsing could you please provide any link or tutorial for marshalling into java objects.
Thanks in advance.
Ugender Rekulampally
Ranch Hand

Joined: Nov 14, 2005
Posts: 130
Divya,
follow this link for marshalling (generating XML document using JAVA objects)

http://www.onjava.com/pub/a/onjava/2004/12/15/jaxb.html
and you search/google for unmarshalling (XML document to Java objects) which you want to look into.

I couldn't find a proper link for unmarshalling so get familiarize with marshalling first and unmarshalling will be real easy (just opposite to marshalling).

post any questions you have while you are working on unmarshalling.

Thanks,
Ugender
praveen oruganti
Ranch Hand

Joined: Feb 05, 2007
Posts: 73
use Castor Framework.

Just convert the first Xml into object and second xml into object and then compare.

Then marshal it.


Regards,<br />Praveen Oruganti<br />Software Programmer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compare two XML files using DOM parser
 
Similar Threads
Jasper Report. Problem in html print preview of graphical element
doubt in parsing file using DOM parser
Need help in modifying XML text value using DOm parser
Edit XML file and need to insert textvalues in that
Submitting input type=button with enter