Joomla! 1.5 API

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2011 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.

 Class JSimpleXMLElement

Description

SimpleXML Element

This object stores all of the direct children of itself in the $children array. They are also stored by type as arrays. So, if, for example, this tag had 2 <font> tags as children, there would be a class member called $font created as an array. $font[0] would be the first font tag, and $font[1] would be the second.

To loop through all of the direct children of this object, the $children member should be used.

To loop through all of the direct children of a specific tag for this object, it is probably easier to use the arrays of the specific tag names, as explained above.

  • since: 1.5

Located in /joomla/utilities/simplexml.php (line 358)

Class JObject   (Subpackage Base)

Class JSimpleXMLElement   (Subpackage Utilities)
Variable Summary
Variable array $_attributes
Variable array $_children
Variable string $_data
Variable int $_level
Variable string $_name
Method Summary
Constructor JSimpleXMLElement __construct (string $name, [array $attrs = array()], [ $level = 0], int $parents)
Method void addAttribute (string $name,  $value, array $attrs)
Method JSimpleXMLElement &addChild (string $name, [array $attrs = array()], [int $level = null])
Method mixed attributes ([string $attribute = null])
Method array children ()
Method string data ()
Method int level ()
Method void map (string $callback, [array $args = array()])
Method string name ()
Method void removeAttribute (string $name)
Method void removeChild ( &$child)
Method string setData (string $data)
Method string toString ([ $whitespace = true])
Variables
array $_attributes = array() (line 365)

Array with the attributes of this XML element

array $_children = array() (line 386)

Array of references to the objects of all direct children of this XML object

string $_data = '' (line 379)

The data the element contains

int $_level = 0 (line 393)

The level of this XML element

string $_name = '' (line 372)

The name of the element

Inherited Variables

Inherited from JObject

Variable JObject::$_errors
Methods
Constructor __construct (line 403)

Constructor, sets up all the default values

JSimpleXMLElement __construct (string $name, [array $attrs = array()],  $level, int $parents)
  • string $name
  • array $attrs
  • int $parents
  • $level

Redefinition of:
JObject::__construct()
Class constructor, overridden in descendant classes.
addAttribute (line 490)

Adds an attribute to the element

void addAttribute (string $name,  $value, array $attrs)
  • string $name
  • array $attrs
  • $value
addChild (line 514)

Adds a direct child to the element

  • return: The added child object
JSimpleXMLElement &addChild (string $name, [array $attrs = array()], [int $level = null])
  • string $name
  • array $attrs
  • int $level
attributes (line 434)

Get the an attribute of the element

  • return: If an attribute is given will return the attribute if it exist. If no attribute is given will return the complete attributes array
  • access: public
mixed attributes ([string $attribute = null])
  • string $attribute: The name of the attribute
children (line 470)

Get the children of the element

  • access: public
array children ()
data (line 449)

Get the data of the element

  • access: public
string data ()
getElementByPath (line 567)

Get an element in the document by / separated path

object JSimpleXMLElement &getElementByPath (string $path)
  • string $path: The / separated path to the element
level (line 480)

Get the level of the element

  • access: public
int level ()
map (line 605)

traverses the tree calling the $callback( JSimpleXMLElement $this, mixed $args=array() ) function with each JSimpleXMLElement.

void map (string $callback, [array $args = array()])
  • string $callback: function name
  • array $args
name (line 421)

Get the name of the element

  • access: public
string name ()
removeAttribute (line 501)

Removes an attribute from the element

void removeAttribute (string $name)
  • string $name
removeChild (line 541)
void removeChild ( &$child)
  • &$child
setData (line 460)

Set the data of the element

  • access: public
string setData (string $data)
  • string $data
toString (line 622)

Return a well-formed XML string based on SimpleXML element

string toString ([ $whitespace = true])
  • $whitespace

Redefinition of:
JObject::toString()
Object-to-string conversion.

Inherited Methods

Inherited From JObject

 JObject::JObject()
 JObject::__construct()
 JObject::get()
 JObject::getError()
 JObject::getErrors()
 JObject::getProperties()
 JObject::getPublicProperties()
 JObject::set()
 JObject::setError()
 JObject::setProperties()
 JObject::toString()
Support Joomla!