posted 18 years ago
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 ]
Good luck for Certfication.