JSimpleXMLElement
Extends \JObjectSimpleXML 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.
| package |
Joomla.Platform |
|---|---|
| subpackage |
Utilities |
| see | |
| since |
11.1 |
| deprecated |
12.1 Use SimpleXMLElement instead |
Methods
__construct
Class constructor, overridden in descendant classes.
__construct(mixed $properties = null)
| since |
11.1 |
|---|
Arguments
- $properties
mixedEither and associative array or another object to set the initial properties of the object.
__toString
Magic method to convert the object to a string gracefully.
__toString() : string
| since |
11.1 |
|---|---|
| deprecated |
12.3 Classes should provide their own __toString() implementation. |
Response
stringThe classname.
addAttribute
Adds an attribute to the element
addAttribute(string $name, array $value) : void
| deprecated |
12.1 |
|---|---|
| since |
11.1 |
Arguments
- $name
stringThe key- $value
arrayThe value for the key
addChild
Adds a direct child to the element
addChild(string $name, array $attrs = array(), integer $level = null) : \JSimpleXMLElement
| deprecated |
12.1 |
|---|---|
| since |
11.1 |
Arguments
- $name
stringThe name of the element.- $attrs
arrayAn key-value array of the element attributes.- $level
integerThe level of the element (optional).
Response
\JSimpleXMLElementThe added child object
attributes
Get the an attribute of the element
attributes(string $attribute = null) : mixed
| deprecated |
12.1 |
|---|---|
| since |
11.1 |
Arguments
- $attribute
stringThe name of the attribute
Response
mixedIf an attribute is given will return the attribute if it exist.
If no attribute is given will return the complete attributes array
children
Get the children of the element
children() : array
| deprecated |
12.1 |
|---|---|
| since |
11.1 |
Response
array
data
Get the data of the element
data() : string
| deprecated |
12.1 Use SimpleXMLElement |
|---|---|
| since |
11.1 |
Response
string
def
Sets a default value if not alreay assigned
def(string $property, mixed $default = null) : mixed
| since |
11.1 |
|---|
Arguments
- $property
stringThe name of the property.- $default
mixedThe default value.
Response
mixed
get
Returns a property of the object or the default value if the property is not set.
get(string $property, mixed $default = null) : mixed
| since |
11.1 |
|---|---|
| see | \JObject::getProperties() |
Arguments
- $property
stringThe name of the property.- $default
mixedThe default value.
Response
mixedThe value of the property.
getElementByPath
Get an element in the document by / separated path
getElementByPath(string $path) : object
| deprecated |
12.1 |
|---|---|
| since |
11.1 |
Arguments
- $path
stringThe / separated path to the element
Response
objectJSimpleXMLElement
getError
Get the most recent error message.
getError(integer $i = null, boolean $toString = true) : string
| since |
11.1 |
|---|---|
| see | \JError |
| deprecated |
12.3 JError has been deprecated |
Arguments
- $i
integerOption error index.- $toString
booleanIndicates if JError objects should return their error message.
Response
stringError message
getErrors
Return all errors, if any.
getErrors() : array
| since |
11.1 |
|---|---|
| see | \JError |
| deprecated |
12.3 JError has been deprecated |
Response
arrayArray of error messages or JErrors.
getProperties
Returns an associative array of object properties.
getProperties(boolean $public = true) : array
| since |
11.1 |
|---|---|
| see | \JObject::get() |
Arguments
- $public
booleanIf true, returns only the public properties.
Response
array
level
Get the level of the element
level() : integer
| since |
11.1 |
|---|---|
| deprecated |
12.1 |
Response
integer
map
Traverses the tree calling the $callback(JSimpleXMLElement $this, mixed $args=array()) function with each JSimpleXMLElement.
map(string $callback, array $args = array()) : void
| deprecated |
12.1 |
|---|---|
| since |
11.1 |
Arguments
- $callback
stringFunction name- $args
arrayThe arguments (optional) for the function callback.
name
Get the name of the element
name() : string
| deprecated |
12.1 |
|---|---|
| since |
11.1 |
Response
string
removeAttribute
Removes an attribute from the element
removeAttribute(string $name) : void
| deprecated |
12.1 |
|---|---|
| since |
11.1 |
Arguments
- $name
stringThe name of the attribute.
removeChild
Remove the child node.
removeChild( &$child) : void
| since |
11.1 |
|---|---|
| deprecated |
12.1 |
Arguments
- $child
set
Modifies a property of the object, creating it if it does not already exist.
set(string $property, mixed $value = null) : mixed
| since |
11.1 |
|---|
Arguments
- $property
stringThe name of the property.- $value
mixedThe value of the property to set.
Response
mixedPrevious value of the property.
setData
Set the data of the element
setData(string $data) : string
| deprecated |
12.1 Use SimpleXMLElement |
|---|---|
| since |
11.1 |
Arguments
- $data
stringThe CDATA for the element.
Response
string
setError
Add an error message.
setError(string $error) : void
| since |
11.1 |
|---|---|
| see | \JError |
| deprecated |
12.3 JError has been deprecated |
Arguments
- $error
stringError message.
setProperties
Set the object properties based on a named array/hash.
setProperties(mixed $properties) : boolean
| since |
11.1 |
|---|---|
| see | \JObject::set() |
Arguments
- $properties
mixedEither an associative array or another object.
Response
boolean
toString
Converts the object to a string (the class name).
toString() : string
Properties
_attributes
Array with the attributes of this XML element
| since |
11.1 |
|---|
Type(s)
array
_name
The name of the element
| since |
11.1 |
|---|
Type(s)
string
_data
The data the element contains
| since |
11.1 |
|---|
Type(s)
string
_children
Array of references to the objects of all direct children of this XML object
| since |
11.1 |
|---|
Type(s)
array
_level
The level of this XML element
| since |
11.1 |
|---|
Type(s)
integer
_errors
An array of error messages or Exception objects.