XML comparison

N

Nick

Hi,

I have an urgent requirement to be done in JAVA where in I need to
compare between two directories and to see if there are exact same
name files available in both the directories. So for eg. DIR1 and DIR2
both have 1.xml, 2.xml then its fine or report the missing ones.

Secondly whichever files are avilable in both the directories compare
them so compare 1.xml in DIR1 to 1.xml in DIR2 but only on certain
fields.

So in summary :

DIR1 -> 1.xml{contents= <a>20</a><b>10</b> }, 2.xml, 3.xml
DIR2 -> 1.xml{contents= <a>25</a> }, 2.xml, 4.xml

Then the report should tell me that

a] 3.xml is missing in DIR2
b] 4.xml is missing in DIR1
c] <a> field in the 1.xml differs
d] But assuming <b> is a fields to be ignored do not display any
error.


Can these be done in JAVA and how ?

Please help.

regards
Nick
 
R

Roedy Green

I have an urgent requirement to be done in JAVA where in I need to
compare between two directories and to see if there are exact same
name files available in both the directories.

Forget XML. Just use Files.list to get your directory listings.

Then sort each if the default order is not suitable.

Then compare. See http://mindprod.com/products1.html#SORTED
for code to compare two lists looking for differences. Just use
standard merge logic.

see http://mindprod.com/jgloss/merge.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top