This does not work with SimpleXML but with DOMDocument which allows to import nodes recursively from one document to the other. Luckily SimpleXML is just a facade on top of DomDocument in PHP and nodes can be imported from SimpleXML to DOM and then within DOM from one document into the other:
$xml = new SimpleXMLElement('<?xml version="1.0"?>
<export>
<config>
<Exported Name="test">
<values>
<node name="yellow" />
<node name="green" />
<node name="red" />
</values>
</Exported>
</config>
</export>');
$target = new SimpleXMLElement('<?xml version="1.0"?>
<main>
<cust>
johndoe@gmail.com
</cust>
</main>');
$cust = dom_import_simplexml($target->cust);
$cust->parentNode->appendChild(
$cust->ownerDocument->importNode(dom_import_simplexml($xml), true)
);
$target->asXML('php://output');
Output:
<?xml version="1.0"?>
<main>
<cust>
johndoe@gmail.com
</cust>
<export>
<config>
<Exported Name="test">
<values>
<node name="yellow"/>
<node name="green"/>
<node name="red"/>
</values>
</Exported>
</config>
</export></main>