class JSimpleXMLElement extends JObject


Located at : UKNOWVA_ROOT/libraries/joomla/utilities/simplexml.php

deprecated

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 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.

Properties

array $_attributes Array with the attributes of this XML element
string $_name The name of the element
string $_data The data the element contains
array $_children Array of references to the objects of all direct children of this XML object
int $_level The level of this XML element

Methods

__construct($name, $attrs = array(), $level)

Constructor, sets up all the default values

string
__toString()

Magic method to convert the object to a string gracefully.

from JObject
mixed
def(string $property, mixed $default = null)

Sets a default value if not alreay assigned

from JObject
mixed
get(string $property, mixed $default = null)

Returns a property of the object or the default value if the property is not set.

from JObject
array
getProperties(boolean $public = true)

Returns an associative array of object properties.

from JObject
string
getError(integer $i = null, boolean $toString = true)

Get the most recent error message.

from JObject
array
getErrors()

Return all errors, if any.

from JObject
mixed
set(string $property, mixed $value = null)

Modifies a property of the object, creating it if it does not already exist.

from JObject
boolean
setProperties(mixed $properties)

Set the object properties based on a named array/hash.

from JObject
void
setError(string $error)

Add an error message.

from JObject
string
toString(boolean $whitespace = true)

Return a well-formed XML string based on SimpleXML element

string
name()

Get the name of the element

mixed
attributes(string $attribute = null)

Get the an attribute of the element

string
data()

Get the data of the element

string
setData(string $data)

Set the data of the element

array
children()

Get the children of the element

integer
level()

Get the level of the element

addAttribute(string $name, array $value)

Adds an attribute to the element

removeAttribute(string $name)

Removes an attribute from the element

addChild(string $name, array $attrs = array(), integer $level = null)

Adds a direct child to the element

removeChild($child)

No description

object
getElementByPath(string $path)

Get an element in the document by / separated path

map(string $callback, array $args = array())

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

Details

at line 443
JObject __construct($name, $attrs = array(), $level)

Constructor, sets up all the default values

Parameters

$name
$attrs
$level

Return Value

JObject

in JObject at line 56
string __toString()

Magic method to convert the object to a string gracefully.

Return Value

string The classname.

in JObject at line 70
mixed def(string $property, mixed $default = null)

Sets a default value if not alreay assigned

Parameters

string $property The name of the property.
mixed $default The default value.

Return Value

mixed

in JObject at line 88
mixed get(string $property, mixed $default = null)

Returns a property of the object or the default value if the property is not set.

Parameters

string $property The name of the property.
mixed $default The default value.

Return Value

mixed The value of the property.

See also

getProperties()

in JObject at line 107
array getProperties(boolean $public = true)

Returns an associative array of object properties.

Parameters

boolean $public If true, returns only the public properties.

Return Value

array

See also

get()

in JObject at line 133
string getError(integer $i = null, boolean $toString = true)

Get the most recent error message.

Parameters

integer $i Option error index.
boolean $toString Indicates if JError objects should return their error message.

Return Value

string Error message

in JObject at line 165
array getErrors()

Return all errors, if any.

Return Value

array Array of error messages or JErrors.

in JObject at line 180
mixed set(string $property, mixed $value = null)

Modifies a property of the object, creating it if it does not already exist.

Parameters

string $property The name of the property.
mixed $value The value of the property to set.

Return Value

mixed Previous value of the property.

in JObject at line 198
boolean setProperties(mixed $properties)

Set the object properties based on a named array/hash.

Parameters

mixed $properties Either an associative array or another object.

Return Value

boolean

See also

set()

in JObject at line 222
void setError(string $error)

Add an error message.

Parameters

string $error Error message.

Return Value

void

at line 671
string toString(boolean $whitespace = true)

Return a well-formed XML string based on SimpleXML element

Parameters

boolean $whitespace True if whitespace should be prepended to the string

Return Value

string

at line 461
string name()

Get the name of the element

Return Value

string

at line 474
mixed attributes(string $attribute = null)

Get the an attribute of the element

Parameters

string $attribute The name of the attribute

Return Value

mixed If an attribute is given will return the attribute if it exist. If no attribute is given will return the complete attributes array

at line 489
string data()

Get the data of the element

Return Value

string

at line 501
string setData(string $data)

Set the data of the element

Parameters

string $data

Return Value

string

at line 511
array children()

Get the children of the element

Return Value

array

at line 520
integer level()

Get the level of the element

Return Value

integer

at line 532
addAttribute(string $name, array $value)

Adds an attribute to the element

Parameters

string $name The key
array $value The value for the key

at line 543
removeAttribute(string $name)

Removes an attribute from the element

Parameters

string $name

at line 558
JSimpleXMLElement addChild(string $name, array $attrs = array(), integer $level = null)

Adds a direct child to the element

Parameters

string $name
array $attrs
integer $level

Return Value

JSimpleXMLElement The added child object

at line 585
removeChild($child)

Parameters

$child

at line 613
object getElementByPath(string $path)

Get an element in the document by / separated path

Parameters

string $path The / separated path to the element

Return Value

object JSimpleXMLElement

at line 651
map(string $callback, array $args = array())

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

Parameters

string $callback function name
array $args