As of PHP 5.1.4, trying to iterate on a non-existent node will actually create that node.
<?
$xml = simplexml_load_string('<root></root>');
foreach($xml->b as $dummy);
echo $xml->asXML();
?>
Gives :
<?xml version="1.0"?>
<root><b/></root>
You might think it is a bug, but PHP developers seam to consider it as a feature : http://bugs.php.net/bug.php?id=39164