I have an XML1:
<letterContent>
<key1>key1</key1>
<key2>key2</key2>
<type>456</type>
<object1>789</object1>
<effectiveDate>00</effectiveDate>
<expandedData />
</letterContent>
... and XML 2:
<expandedData>
<rsnForReg>
<legacyTIN>
<asCurrent>leg123</asCurrent>
</legacyTIN>
<etpmTIN>
<asCurrent>etpm123</asCurrent>
</etpmTIN>
<regType>
<asCurrent/>
</regType>
</rsnForReg>
</expandedData>
I want to insert XML 2 in XML 1 document on the expandedData node using JAVA.
The final XML1 should look like:
<letterContent>
<key1>key1</key1>
<key2>key2</key2>
<type>456</type>
<object1>789</object1>
<effectiveDate>00</effectiveDate>
<expandedData>
<rsnForReg>
<legacyTIN>
<asCurrent>leg123</asCurrent>
</legacyTIN>
<etpmTIN>
<asCurrent>etpm123</asCurrent>
</etpmTIN>
<regType>
<asCurrent/>
</regType>
</rsnForReg>
</expandedData>
</letterContent>
XML2 inserted on the XML1's expandedData node. Any ideas? I know i need to build a recursive function to loop through XML 2 but not sure how to implement it in java.
Consider using XPath: