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
mixed
Either 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
string
The classname.
addAttribute
Adds an attribute to the element
addAttribute(string $name, array $value) : void
deprecated |
12.1 |
---|---|
since |
11.1 |
Arguments
- $name
string
The key- $value
array
The 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
string
The name of the element.- $attrs
array
An key-value array of the element attributes.- $level
integer
The level of the element (optional).
Response
\JSimpleXMLElement
The added child object
attributes
Get the an attribute of the element
attributes(string $attribute = null) : mixed
deprecated |
12.1 |
---|---|
since |
11.1 |
Arguments
- $attribute
string
The name of the attribute
Response
mixed
If 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
string
The name of the property.- $default
mixed
The 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
string
The name of the property.- $default
mixed
The default value.
Response
mixed
The 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
string
The / separated path to the element
Response
object
JSimpleXMLElement
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
integer
Option error index.- $toString
boolean
Indicates if JError objects should return their error message.
Response
string
Error message
getErrors
Return all errors, if any.
getErrors() : array
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Response
array
Array 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
boolean
If 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
string
Function name- $args
array
The 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
string
The 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
string
The name of the property.- $value
mixed
The value of the property to set.
Response
mixed
Previous 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
string
The 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
string
Error message.
setProperties
Set the object properties based on a named array/hash.
setProperties(mixed $properties) : boolean
since |
11.1 |
---|---|
see | \JObject::set() |
Arguments
- $properties
mixed
Either 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.