I understand that to walk through a document using Java/Jaxp DOM you can use recursion, but I am trying to find a way for the following. There are two xml documents 1 and 2. The code needs to loop through the elements of document 2 and check if an element of document 2 exists in document 1. If it does not exist, then the code should add the element at that heirarchy. The problem is, with nesting and all, its complicated. Would greatly appreciate if someone could show if there is a easier way to do this. No assumptions about an existing structure for the xml can be made
Sample XMLs are shown below
Document 1
<employeelist>
<employee>
<id>2134</id>
<name>javaguy</name>
</employee>
<employee>
<id>2134</id>
</employee>
</employeelist>
Document 2
<employeelist>
<employee>
<id>2134</id>
<name>javaguy</name>
</employee>
<employee>
<id>2135</id>
<name>oracleguy</name>
</employee>
</employeelist>
The code should read both docs and update
doc 1 with the name for employee with id 2135 as oracleguy. I can create document elements and all that stuff, so any code snippets to do this should just be great
SCJP 1.4, SCWCD 1.4, SCBCD 1.3, OCA (DBA)<br /> <br />Winners dont do different things. They do things differently...