Bueno un demo, mientras contestas
Código PHP:
Ver original<?php
$xml = <<<XML
<foo>
<bar>
<candy>candy</candy>
<fruits>fruits</fruits>
<vegetable>vegetable</vegetable>
</bar>
<baz>
<candy>candy</candy>
<fruits>fruits</fruits>
</baz>
</foo>
XML;
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml);
$baz = $dom->getElementsByTagName('baz')->item(0);
$vegetable = $dom->createElement('vegetable','vegetable');
$baz->appendChild($vegetable);
echo $dom->saveXML();
/**
* Output:
*<?xml version="1.0"?>
* <foo>
* <bar>
* <candy>candy</candy>
* <fruits>fruits</fruits>
* <vegetable>vegetable</vegetable>
* </bar>
* <baz>
* <candy>candy</candy>
* <fruits>fruits</fruits>
* <vegetable>vegetable</vegetable>
* </baz>
* </foo>
*/