/**
* Adds a new child SimpleXMLElement node to the source.
*
* @param \SimpleXMLElement $source The source element on which to append.
* @param \SimpleXMLElement $new The new element to append.
*
* @return void
*
* @since 1.7.0
*/
protected static function addNode(\SimpleXMLElement $source, \SimpleXMLElement $new)
{
// Add the new child node.
$node = $source->addChild($new->getName(), htmlspecialchars(trim($new)));
// Add the attributes of the child node.
foreach ($new->attributes() as $name => $value) {
$node->addAttribute($name, $value);
}
// Add any children of the new node.
foreach ($new->children() as $child) {
self::addNode($node, $child);
}
}