1
我有一個XML1:插入XML文檔(JAVA)的另一個XML文檔的特定節點
<letterContent>
<key1>key1</key1>
<key2>key2</key2>
<type>456</type>
<object1>789</object1>
<effectiveDate>00</effectiveDate>
<expandedData />
</letterContent>
...和XML 2:
<expandedData>
<rsnForReg>
<legacyTIN>
<asCurrent>leg123</asCurrent>
</legacyTIN>
<etpmTIN>
<asCurrent>etpm123</asCurrent>
</etpmTIN>
<regType>
<asCurrent/>
</regType>
</rsnForReg>
</expandedData>
我想插入XML 2使用JAVA在expandedData節點上創建XML 1文檔。
最終XML1應該是這樣的:
<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插入XML1的expandedData節點上。有任何想法嗎?我知道我需要構建一個循環遍歷XML 2的遞歸函數,但不知道如何在java中實現它。
[克隆dom.Document對象(http://stackoverflow.com/questions/5226852/cloning-dom-document-object) – hakre 2013-03-07 11:30:24