Ok,
you can achieve this with XSLT's xsl:copy-of instruction.
Supposing that your source XML is the first doc you posted and the second is in the file doc2.xml, you can write (not tested):
Code:
<xsl:template macth="A">
<xsl:copy>
<xsl:copy-of select="B"/>
<xsl:copy-of select="document('doc2.xml')/A/B"/>
</xsl:copy>
</xsl:template>
Without XSLT it's probably impossible (in standard W3C DOM), since in
any case you have to get the node-set from one document and add every node in that nodeset to another (so looping can't be avoided). Or you can use dom4j API (using Node.detach() and Branch.addElement() methods to "transfer" a node from one XML doc to another) and you can avoid looping construct(you get the nodeset using XPath expression, which is really a powerful thing ;)) since the transfer process will be done in so-called event-based mode. So you write event-handlers and you'll never have looping constructs.
Regards,
Armen