PHP Class Horde_Xml_Element, horde

Author: Chuck Hagenbuch ([email protected])
Inheritance: implements ArrayAccess
ファイルを表示 Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_appended boolean
$_children array
$_element DOMElement
$_namespaces array
$_parentElement Horde_Xml_Element
$_serialized string A string representation of the element, used when serializing/unserializing.

Public Methods

Method Description
__call ( string $var, $unused ) : mixed Get the value of an element with method syntax.
__construct ( $element ) Horde_Xml_Element constructor.
__get ( string $var ) : mixed Map variable access onto the underlying entry representation.
__isset ( $var ) Map isset calls onto the underlying entry representation.
__set ( string $var, string $val ) Map variable sets onto the underlying entry representation.
__sleep ( ) : array Prepare for serialization
__toString ( ) Returns the nodeValue of this element when this object is used in a string context.
__unset ( $var ) Remove all children matching $var.
__wakeup ( ) Unserialization handler; handles $this->_element being an instance of DOMElement or Horde_Xml_Element, or parses it as an XML string.
appendChild ( Horde_Xml_Element $element ) Append a child node to this element.
fromArray ( $array ) 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 ( $prefix ) : string Get the full version of a namespace prefix
offsetExists ( $offset ) Required by the ArrayAccess interface.
offsetGet ( $offset ) Required by the ArrayAccess interface.
offsetSet ( $offset, $value ) Required by the ArrayAccess interface.
offsetUnset ( $offset ) Required by the ArrayAccess interface.
registerNamespace ( string $prefix, string $namespaceURI ) Add a namespace and prefix to the registered list
saveXml ( $formatted = false ) : string Get an XML string representation of this element
saveXmlFragment ( $formatted = false ) : string Get the XML for only this element
setDom ( DOMElement $element ) Update the object from a DOM element
setParent ( Horde_Xml_Element $element ) Set the parent element of this object to another Horde_Xml_Element.

Protected Methods

Method Description
_cacheChildren ( ) Build a cache of child nodes.
_children ( $var ) : array Finds children with tagnames matching $var
_ensureAppended ( ) Appends this element to its parent if necessary.
_expireCachedChildren ( ) Expire cached children.

Method Details

__call() public method

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.
public __call ( string $var, $unused ) : mixed
$var string The element to get the string value of.
return mixed The node's value, null, or an array of nodes.

__construct() public method

Horde_Xml_Element constructor.
public __construct ( $element )

__get() public method

Get-style access returns a Horde_Xml_Element representing the child element accessed. To get string values, use method syntax with the __call() overriding.
public __get ( string $var ) : mixed
$var string The property to access.
return mixed

__isset() public method

Map isset calls onto the underlying entry representation.
public __isset ( $var )

__set() public method

Map variable sets onto the underlying entry representation.
public __set ( string $var, string $val )
$var string The property to change.
$val string The property's new value.

__sleep() public method

Prepare for serialization
public __sleep ( ) : array
return array

__toString() public method

Returns the nodeValue of this element when this object is used in a string context.
public __toString ( )

__unset() public method

Remove all children matching $var.
public __unset ( $var )

__wakeup() public method

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

_cacheChildren() protected method

Build a cache of child nodes.
protected _cacheChildren ( )

_children() protected method

Similar to SimpleXML's children() method.
protected _children ( $var ) : array
return array

_ensureAppended() protected method

Appends this element to its parent if necessary.
protected _ensureAppended ( )

_expireCachedChildren() protected method

Expire cached children.
protected _expireCachedChildren ( )

appendChild() public method

Append a child node to this element.
public appendChild ( Horde_Xml_Element $element )
$element Horde_Xml_Element The element to append.

fromArray() public method

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
public fromArray ( $array )
$array Hash to import into this element.

getDom() public method

Returns the underlying DOM object, which can then be manipulated with full DOM methods.
public getDom ( ) : DOMElement
return DOMElement

lookupNamespace() public static method

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.
public static lookupNamespace ( $prefix ) : string
return string

offsetExists() public method

Required by the ArrayAccess interface.
public offsetExists ( $offset )

offsetGet() public method

Required by the ArrayAccess interface.
public offsetGet ( $offset )

offsetSet() public method

Required by the ArrayAccess interface.
public offsetSet ( $offset, $value )

offsetUnset() public method

Required by the ArrayAccess interface.
public offsetUnset ( $offset )

registerNamespace() public static method

Takes a prefix and a full namespace URI and adds them to the list of registered namespaces for use by Horde_Xml_Element::lookupNamespace().
public static registerNamespace ( string $prefix, string $namespaceURI )
$prefix string The namespace prefix
$namespaceURI string The full namespace URI

saveXml() public method

Returns a string of this element's XML, including the XML prologue.
public saveXml ( $formatted = false ) : string
return string

saveXmlFragment() public method

Returns a string of this element's XML without prologue.
public saveXmlFragment ( $formatted = false ) : string
return string

setDom() public method

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.
public setDom ( DOMElement $element )
$element DOMElement

setParent() public method

Set the parent element of this object to another Horde_Xml_Element.
public setParent ( Horde_Xml_Element $element )
$element Horde_Xml_Element

Property Details

$_appended protected_oe property

protected bool $_appended
return boolean

$_children protected_oe property

protected array $_children
return array

$_element protected_oe property

protected DOMElement $_element
return DOMElement

$_namespaces protected_oe static_oe property

protected static array $_namespaces
return array

$_parentElement protected_oe property

protected Horde_Xml_Element $_parentElement
return Horde_Xml_Element

$_serialized protected_oe property

A string representation of the element, used when serializing/unserializing.
protected string $_serialized
return string