Comparing the Source XML with Destination XML and want to add the missing tags to the Destination XML.
In this case tag <abcd></abcd> is missing from the Destination XML. But when I tried to import this specific node to the Destination node result is Merged XML which is not as per my expectation. Expected needs to be identical to Source XML.
Source XML
<Adapter>
<Module id="BL">
<gl>Y</gl>
<glActivitySeries>AC</glActivitySeries>
<target>FIC.BL</target>
<abcd></abcd>
</Module>
</Adapter>
Destination XML
<Adapter>
<Module id="BL">
<gl>Y</gl>
<glActivitySeries>AC</glActivitySeries>
<target>FIC.BL</target>
</Module>
</Adapter>
Merged XML
<Adapter>
<Module id="BL">
<gl>Y</gl>
<glActivitySeries>AC</glActivitySeries>
<target>FIC.BL</target>
</Module>
<abcd/>
</Adapter>
我的Java代码
获取源XML中缺少的节点
NodeList tempNodeList=node.getElementsByTagName("abcd");
tempNodeList.item(0);
将该节点导入到目标XML
Node newTempNode = destDocument.importNode(requiredNode,true);
destDocument.getDocumentElement().appendChild(newTempNode);
代码中的错误是什么导致我的输出不符合我的预期。任何领先的企业都可以。