Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compare two XML files using DOM parser

 
Divya Gehlot
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Craig Bayley
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use Castor Framework.

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

Then marshal it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic