Comparing two xmls based on keys....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick

    Comparing two xmls based on keys....

    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
Working...