• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compare 2 xml files

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
How do i compare 2 xml files.
i cant use unix diff.
a.xml
b.xml

i need to get each element in a.xml and its value.
and compare it with the same element in b.xml

a.xml
<root>
<msg> helloworld</msg>
<id> 1 </id>
<msg> hai</msg>
<id> 2 </id>


..
</root>
b.xml

<root>
<msg> welcome</msg>
<id> 1 </id>
<msg> hai</msg>
<id> 3 </id>
..
</root>



here we see msg changed for that tag. helloworld to welcome and also id changed 2 to 3.
the xml will have same structure. same number of tags , only values may change.

Technolgy:
I am using jdk 1.5
import java.xml.xpath.*;
import org.xml.sax.*
in new jdk.15 i guess no need to use jdom.

i would like to have
$java Compare a.xml b.xml

output:
Change: <msg> [helloworld] changedto [welcome]
Change: <id> [2] changedto [3]

Thanks

[ December 21, 2005: Message edited by: Rayudu addagarla ]

[ December 21, 2005: Message edited by: Rayudu addagarla ]
[ December 21, 2005: Message edited by: Rayudu addagarla ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a JSP questiom. Please be sure to post your questions in the appropriate forum.

Moved to the XML fourm.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic