class XmlHelper (View source)

Simple Xml Helper to get attributes from \SimpleXMLElement

Methods

static mixed
getAttribute(SimpleXMLElement $xml, string $attr, mixed $default = null)

Get attribute from SimpleXMLElement.

static mixed
get(SimpleXMLElement $xml, string $attr, mixed $default = null)

Get attribute from SimpleXMLElement. Alias of getAttribute().

static mixed
getBool(SimpleXMLElement $xml, string $attr, mixed $default = null)

Method to convert some string like true, 1, yes to boolean TRUE, and no, false, disabled, null, none, 0 string to boolean FALSE.

static mixed
getFalse(SimpleXMLElement $xml, string $attr, mixed $default = null)

Just an alias of getBool() but FALSE will return TRUE.

static array
getAttributes(SimpleXMLElement $xml)

Get all attributes.

static void
def(SimpleXMLElement $xml, string $attr, string $value)

If this attribute not exists, use this value as default, or we use original value from xml.

Details

at line line 52
static mixed getAttribute(SimpleXMLElement $xml, string $attr, mixed $default = null)

Get attribute from SimpleXMLElement.

Parameters

SimpleXMLElement $xml A SimpleXMLElement object.
string $attr The attribute name.
mixed $default The default value.

Return Value

mixed The return value of this attribute.

at line line 71
static mixed get(SimpleXMLElement $xml, string $attr, mixed $default = null)

Get attribute from SimpleXMLElement. Alias of getAttribute().

Parameters

SimpleXMLElement $xml A SimpleXMLElement object.
string $attr The attribute name.
mixed $default The default value.

Return Value

mixed The return value of this attribute.

at line line 86
static mixed getBool(SimpleXMLElement $xml, string $attr, mixed $default = null)

Method to convert some string like true, 1, yes to boolean TRUE, and no, false, disabled, null, none, 0 string to boolean FALSE.

Parameters

SimpleXMLElement $xml A SimpleXMLElement object.
string $attr The attribute name.
mixed $default The default value.

Return Value

mixed The return value of this attribute.

at line line 107
static mixed getFalse(SimpleXMLElement $xml, string $attr, mixed $default = null)

Just an alias of getBool() but FALSE will return TRUE.

Parameters

SimpleXMLElement $xml A SimpleXMLElement object.
string $attr The attribute name.
mixed $default The default value.

Return Value

mixed The return value of this attribute.

at line line 119
static array getAttributes(SimpleXMLElement $xml)

Get all attributes.

Parameters

SimpleXMLElement $xml A SimpleXMLElement object.

Return Value

array The return values of all attributes.

at line line 140
static void def(SimpleXMLElement $xml, string $attr, string $value)

If this attribute not exists, use this value as default, or we use original value from xml.

Parameters

SimpleXMLElement $xml A SimpleXMLElement object.
string $attr The attribute name.
string $value The value to set as default.

Return Value

void