Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Comparing two xmls based on keys....

Reply
Thread Tools

Comparing two xmls based on keys....

 
 
Nick
Guest
Posts: n/a
 
      06-17-2008
Hi,

I need to compare two xml files. Which contain multiple xml datas
based on a key.

So for eg. I have two xmls A.xml and B.xml.

A.xml :
<?xml version="1.0" encoding="UTF-8"?>
<Test >
<Item>1</Item>
<Name>Orange</Name>
</Test>
<Test >
<Item>2</Item>
<Name>Apple</Name>
</Test>

Whereas B.xml :

<?xml version="1.0" encoding="UTF-8"?>
<Test >
<Item>2/Item>
<Name>Apple</Name>
</Test>
<Test >
<Item>1</Item>
<Name>Orange</Name>
</Test>

If you compare tags row by row then the xmls won't match but if you
keep the Item as the key then both the xmls are equal.
Item : 1 / Name : Orange
Item : 2 / Name : Apple

How can you do such comparison in Java

Cheers
Nick
 
Reply With Quote
 
 
 
 
Joseph J. Kesselman
Guest
Posts: n/a
 
      06-17-2008
Nick wrote:
> How can you do such comparison in Java


Sounds like a class assignment. Shouldn't be hard. I'd suggest using a
SAX parser to load the data from the first document into an
application-specific data structure, then to load the data from the
second document and check it off against the first. Don't forget to
handle the cases of more items present, fewer items present, and
duplicate items. Have fun,
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing RFC1123 based Dates Phoe6 Python 3 08-05-2007 02:22 PM
Receiving XMLs over the Internet suspended@gmail.com XML 1 12-21-2006 08:53 PM
Problem combining two XMLs using XSLT Stefan XML 2 01-27-2006 01:07 PM
edit xmls like maalej XML 3 08-17-2005 11:59 PM
2 xmls maalej XML 1 04-23-2005 08:51 AM



Advertisments