File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes compare the two  xml file generate the third xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "compare the two  xml file generate the third xml" Watch "compare the two  xml file generate the third xml" New topic

compare the two xml file generate the third xml

punna Kumar
Ranch Hand

Joined: Feb 28, 2005
Posts: 80
i have a requirement to compare the two xml data and generate the defference xml containing the differnce data,

any one give the idea how i can do , i am using DOM Parser for parseing the xml file.

any idea

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42956
It's probably less effort if you use one of the available xmldiff tools (google for it), and then use the results of that, than it is to roll your own.
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
We faced the same situation once, we wrote a script using Jdom it will take a node from the file 1 and parse the next XML. This happens in a recursive fashion. ( Dont know may be it's a expensive approach )
Even Text pad editor was helful, it checks the differences between two files.
[ November 09, 2005: Message edited by: Srinivasa Raghavan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
punna Kumar
Ranch Hand

Joined: Feb 28, 2005
Posts: 80
thanks for giving the approches,
here i have to take the two transations difference data i mean to say before the transationa and after transation, what is the data is modified.
based on modified data i have to create the xml. these things i have to do throug programatically , because these transations include the data bae operation, i am useing oracle 9i

i can do any thing with oracle

i mean comapre the data and generate the xml in back end it self

please help me?

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I tried this once but didn't go very far with it. My idea was ...

Now you have to define "match". Is it a match on the tag? On some or all of the attributes? On a simple String value? I think that's where I gave up on the XML I wanted to compare ... it had many repeats of the same tag name so I had to drill into attributes and children to even match two of them. Ick.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: compare the two xml file generate the third xml