note 98993 deleted from simplexmlelement.addChild by danbrown
| From: | danbrown@php.net | Date: | Fri, 28 Jan 2011 14:34:12 +0000 |
| Subject: | note 98993 deleted from simplexmlelement.addChild by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176452@lists.php.net to get a copy of this message | ||
Note Submitter: dal-pa_c at epitech dot eu
----
If You want to add another XML-Element as shown former by "Lutz Elsner", but also want to
consider the NameSpace, extend the given function as shown:
<?php
public function AddXMLElement(SimpleXMLElement $dest, SimpleXMLElement $source, $ns = NULL)
{
$new_dest = $dest->addChild($source->getName(), $source[0], $ns);
foreach ($source->attributes($ns) as $name => $value)
{
$new_dest->addAttribute($name, $value, $ns);
}
foreach ($source->children($ns) as $child)
{
AddXMLElement($new_dest, $child, $ns);
}
}
?>