\Horde_Xml_Element

Wraps a DOMElement allowing for SimpleXML-like access to attributes.

Summary

Methods
Properties
Constants
lookupNamespace()
registerNamespace()
__construct()
getDom()
setDom()
fromArray()
appendChild()
saveXml()
saveXmlFragment()
__wakeup()
__sleep()
__get()
__set()
__isset()
__call()
__unset()
TAGNAME()
No public properties found
No constants found
_children()
_cacheChildren()
_expireCachedChildren()
$_namespaces
$_element
$_serialized
$_parentElement
$_children
$_appended
N/A
No private methods found
No private properties found
N/A

Properties

$_namespaces

$_namespaces : array

Type

array

$_element

$_element : \DOMElement

Type

\DOMElement

$_serialized

$_serialized : string

A string representation of the element, used when serializing/unserializing.

Type

string

$_children

$_children : array

Type

array

$_appended

$_appended : boolean

Type

boolean

Methods

lookupNamespace()

lookupNamespace(  $prefix) : string

Get the full version of a namespace prefix

Looks up a prefix (atom:, etc.) in the list of registered namespaces and returns the full namespace URI if available. Returns the prefix, unmodified, if it's not registered.

Parameters

$prefix

Returns

string

registerNamespace()

registerNamespace(string  $prefix, string  $namespaceURI) 

Add a namespace and prefix to the registered list

Takes a prefix and a full namespace URI and adds them to the list of registered namespaces for use by Horde_Xml_Element::lookupNamespace().

Parameters

string $prefix

The namespace prefix

string $namespaceURI

The full namespace URI

__construct()

__construct(  $element) 

Horde_Xml_Element constructor.

Parameters

$element

getDom()

getDom() : \DOMElement

Get a DOM representation of the element

Returns the underlying DOM object, which can then be manipulated with full DOM methods.

Returns

\DOMElement

setDom()

setDom(\DOMElement  $element) 

Update the object from a DOM element

Take a DOMElement object, which may be originally from a call to getDom() or may be custom created, and use it as the DOM tree for this Horde_Xml_Element.

Parameters

\DOMElement $element

fromArray()

fromArray(  $array) 

Add child elements and attributes to this element from a simple key => value hash. Keys can be:

ElementName -> <$ElementName> will be appended with a value of $value

AttributeName -> An attribute $AttributeName will be

                           added to this element with a value
                           of $value

ElementName#AttributeName -> <$ElementName> will be appended to this element if it doesn't already exist, and have its attribute $AttributeName set to $value

Parameters

$array

Hash to import into this element.

appendChild()

appendChild(\Horde_Xml_Element  $element) 

Append a child node to this element.

Parameters

\Horde_Xml_Element $element

The element to append.

saveXml()

saveXml(  $formatted = false) : string

Get an XML string representation of this element

Returns a string of this element's XML, including the XML prologue.

Parameters

$formatted

Returns

string

saveXmlFragment()

saveXmlFragment(  $formatted = false) : string

Get the XML for only this element

Returns a string of this element's XML without prologue.

Parameters

$formatted

Returns

string

__wakeup()

__wakeup() 

Unserialization handler; handles $this->_element being an instance of DOMElement or Horde_Xml_Element, or parses it as an XML string.

__sleep()

__sleep() : array

Prepare for serialization

Returns

array

__get()

__get(string  $var) : mixed

Map variable access onto the underlying entry representation.

Get-style access returns a Horde_Xml_Element representing the child element accessed. To get string values, use method syntax with the __call() overriding.

Parameters

string $var

The property to access.

Returns

mixed

__set()

__set(string  $var, string  $val) 

Map variable sets onto the underlying entry representation.

Parameters

string $var

The property to change.

string $val

The property's new value.

__isset()

__isset(  $var) 

Map isset calls onto the underlying entry representation.

Parameters

$var

__call()

__call(string  $var,   $unused) : mixed

Get the value of an element with method syntax.

Map method calls to get the string value of the requested element. If there are multiple elements that match, this will return an array of those objects.

Parameters

string $var

The element to get the string value of.

$unused

Returns

mixed —

The node's value, null, or an array of nodes.

__unset()

__unset(  $var) 

Remove all children matching $var.

Parameters

$var

TAGNAME()

TAGNAME() : mixed

To get the un-wrapped value of a node, use method syntax ($xml_element->tagname()). This will return the string value of the tag if it is a single tag, an array of Horde_Xml_Element objects if there are multiple tags, or null if the tag does not exist.

Returns

mixed

_children()

_children(  $var) : array

Finds children with tagnames matching $var

Similar to SimpleXML's children() method.

Parameters

$var

Returns

array

_cacheChildren()

_cacheChildren() 

Build a cache of child nodes.

_expireCachedChildren()

_expireCachedChildren() 

Expire cached children.