Back to Form class

Method addNode

protected static void
addNode
(\SimpleXMLElement $source, \SimpleXMLElement $new)
Adds a new child SimpleXMLElement node to the source.
Parameters
  • \SimpleXMLElement $source The source element on which to append.
  • \SimpleXMLElement $new The new element to append.
Returns
  • void
Since
  • 1.7.0
Class: Form
Project: Joomla

Method addNode - Source code

/**
 * 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);
    }
}