我有两个单独的 java Document 对象:
文档 1:
<CIS_REQUEST>
<Request1>
</CIS_REQUEST>
<CIS_RESPONSE>
<RESPONSE1>
<RESPONSE2>
</CIS_RESPONSE>
文件 2:
<CIS_REQUEST>
<Request1>
</CIS_REQUEST>
我希望生成的文档如下所示:
<CIS_REQUEST>
<Request1>
</CIS_REQUEST>
<CIS_RESPONSE>
<RESPONSE1>
<RESPONSE2>
</CIS_RESPONSE>
<PROCESSING>1</PROCESSING>
<CIS_PROFILES>
<CIS_REQUEST>
<Request1>
</CIS_REQUEST>
<CIS_PROFILES>
我到目前为止的代码:
Document doc2 = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(combinedResponse);
counter++;
String counter_str = Integer.toString(counter);
Element count = doc2.createElement("PROCESSING");
root.appendChild(count);
Text counter_text = doc2.createTextNode(counter_str);
count.appendChild(counter_text);
Element profileElement = doc2.createElement(profName + "_profiles");
profileElement.append(doc1) //I need some replacement for this code.
谁能教育我如何将一个文档附加到另一个文档,而不是将其插入原始文档的某个位置?