Documentation

Horde_Xml_Element
in package
implements ArrayAccess

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

Tags
author

Chuck Hagenbuch chuck@horde.org

license

http://www.horde.org/licenses/bsd BSD

category

Horde

Interfaces, Classes, Traits and Enums

ArrayAccess

Table of Contents

$_appended  : bool
$_children  : array<string|int, mixed>
$_element  : DOMElement
$_namespaces  : array<string|int, mixed>
$_parentElement  : Horde_Xml_Element
$_serialized  : string
A string representation of the element, used when serializing/unserializing.
__call()  : mixed
Get the value of an element with method syntax.
__construct()  : mixed
Horde_Xml_Element constructor.
__get()  : mixed
Map variable access onto the underlying entry representation.
__isset()  : mixed
Map isset calls onto the underlying entry representation.
__set()  : mixed
Map variable sets onto the underlying entry representation.
__sleep()  : array<string|int, mixed>
Prepare for serialization
__unset()  : mixed
Remove all children matching $var.
__wakeup()  : mixed
Unserialization handler; handles $this->_element being an instance of DOMElement or Horde_Xml_Element, or parses it as an XML string.
appendChild()  : mixed
Append a child node to this element.
fromArray()  : mixed
Add child elements and attributes to this element from a simple key => value hash. Keys can be:
getDom()  : DOMElement
Get a DOM representation of the element
lookupNamespace()  : string
Get the full version of a namespace prefix
registerNamespace()  : mixed
Add a namespace and prefix to the registered list
saveXml()  : string
Get an XML string representation of this element
saveXmlFragment()  : string
Get the XML for only this element
setDom()  : mixed
Update the object from a DOM element
TAGNAME()  : mixed
_cacheChildren()  : mixed
Build a cache of child nodes.
_children()  : array<string|int, mixed>
Finds children with tagnames matching $var
_expireCachedChildren()  : mixed
Expire cached children.

Properties

$_appended

protected bool $_appended = \true

$_children

protected array<string|int, mixed> $_children = \null

$_element

protected DOMElement $_element

$_namespaces

protected static array<string|int, mixed> $_namespaces = array('opensearch' => 'http://a9.com/-/spec/opensearchrss/1.0/', 'atom' => 'http://www.w3.org/2005/Atom', 'rss' => 'http://blogs.law.harvard.edu/tech/rss', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns')

$_serialized

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

protected string $_serialized

Methods

__call()

Get the value of an element with method syntax.

public __call(string $var, mixed $unused) : mixed

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
$var : string

The element to get the string value of.

$unused : mixed
Return values
mixed

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

__construct()

Horde_Xml_Element constructor.

public __construct(mixed $element) : mixed
Parameters
$element : mixed
Return values
mixed

__get()

Map variable access onto the underlying entry representation.

public __get(string $var) : mixed

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
$var : string

The property to access.

Return values
mixed

__isset()

Map isset calls onto the underlying entry representation.

public __isset(mixed $var) : mixed
Parameters
$var : mixed
Return values
mixed

__set()

Map variable sets onto the underlying entry representation.

public __set(string $var, string $val) : mixed
Parameters
$var : string

The property to change.

$val : string

The property's new value.

Return values
mixed

__sleep()

Prepare for serialization

public __sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unset()

Remove all children matching $var.

public __unset(mixed $var) : mixed
Parameters
$var : mixed
Return values
mixed

__wakeup()

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

public __wakeup() : mixed
Return values
mixed

fromArray()

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

public fromArray( $array) : mixed

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.

Return values
mixed

getDom()

Get a DOM representation of the element

public getDom() : DOMElement

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

Return values
DOMElement

lookupNamespace()

Get the full version of a namespace prefix

public static lookupNamespace(mixed $prefix) : string

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 : mixed
Return values
string

registerNamespace()

Add a namespace and prefix to the registered list

public static registerNamespace(string $prefix, string $namespaceURI) : mixed

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
$prefix : string

The namespace prefix

$namespaceURI : string

The full namespace URI

Return values
mixed

saveXml()

Get an XML string representation of this element

public saveXml([mixed $formatted = false ]) : string

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

Parameters
$formatted : mixed = false
Return values
string

saveXmlFragment()

Get the XML for only this element

public saveXmlFragment([mixed $formatted = false ]) : string

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

Parameters
$formatted : mixed = false
Return values
string

setDom()

Update the object from a DOM element

public setDom(DOMElement $element) : mixed

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
$element : DOMElement
Return values
mixed

TAGNAME()

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

Return values
mixed

_cacheChildren()

Build a cache of child nodes.

protected _cacheChildren() : mixed
Return values
mixed

_children()

Finds children with tagnames matching $var

protected _children(mixed $var) : array<string|int, mixed>

Similar to SimpleXML's children() method.

Parameters
$var : mixed
Return values
array<string|int, mixed>

_expireCachedChildren()

Expire cached children.

protected _expireCachedChildren() : mixed
Return values
mixed

Search results