JSimpleXMLElement/addChild
From Joomla! Documentation
< API16:JSimpleXMLElementRevision as of 17:56, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description===
Adds a direct child to the element
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<now...)
Revision as of 17:56, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description===
Adds a direct child to the element
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<now...)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Adds a direct child to the element
Template:Description:JSimpleXMLElement/addChild
Syntax[edit]
addChild($name, $attrs=array(), $level=null)
Parameter Name | Default Value | Description |
---|---|---|
$name | $name | |
$attrs | array() | $attrs |
$level | null | $level |
Returns[edit]
The added child object
Defined in[edit]
libraries/joomla/utilities/simplexml.php
Importing[edit]
jimport( 'joomla.utilities.simplexml' );
Source Body[edit]
function addChild($name, $attrs = array(), $level = null)
{
//If there is no array already set for the tag name being added,
//create an empty array for it
if (!isset($this->$name)) {
$this->$name = array();
}
// set the level if not already specified
if ($level == null) {
$level = ($this->_level + 1);
}
//Create the child object itself
$classname = get_class($this);
$child = new $classname($name, $attrs, $level);
//Add the reference of it to the end of an array member named for the elements name
$this->{$name}[] = &$child;
//Add the reference to the children array member
$this->_children[] = &$child;
//return the new child
return $child;
}
[Edit See Also] Template:SeeAlso:JSimpleXMLElement/addChild
Examples[edit]
<CodeExamplesForm />