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
RedGrittyBrick - 17 Apr 2008 16:39 GMT
> Hi,
>
[quoted text clipped - 21 lines]
>
> Can these be done in JAVA
Yes. It could also be done in many other programming languages.
> and how ?
Since it is urgent and you don't know how to get started, I think you'd
best hire a Java programmer who is familiar with XML.

Signature
RGB
Alex.From.Ohio.Java@gmail.com - 17 Apr 2008 20:10 GMT
> Hi,
>
[quoted text clipped - 26 lines]
> regards
> Nick
That's pretty common task.
Use XML DOM parser and you can compare certain fields easily and
quickly.
Alex.
http://www.myjavaserver.com/~alexfromohio/
Andy Chambers - 07 May 2008 13:53 GMT
> Hi,
>
[quoted text clipped - 21 lines]
>
> Can these be done in JAVA and how ?
The first two are fairly trivial. Look at the File class in the
javadocs to see how you might access the information you need.
For the last two, you'll probably want to use xpath. xpath allows you
to query your xml document as if it were a filesystem. For example
<xsl:value-of select="count(//a)"/>
would return a count of all "a" elements in your document. xalan
provides a free java api for using xpath.
--
Andy