Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
XML_Tree_Node Class Reference

Public Member Functions

 XML_Tree_Node ($name, $content= '', $attributes=array(), $lineno=null, $use_cdata_section=null)
 
addChild ($child, $content= '', $attributes=array(), $lineno=null, $use_cdata_section=null)
 
cloneNode ()
 
insertChild ($path, $pos, &$child, $content= '', $attributes=array())
 
removeChild ($pos)
 
 registerName ($name, $path)
 
get ($use_cdata_section=false)
 
 getAttribute ($name)
 
 setAttribute ($name, $value= '')
 
 unsetAttribute ($name)
 
 setContent ($content, $use_cdata_section=null)
 
getElement ($path)
 
getNodeAt ($path)
 
 encodeXmlEntities ($xml)
 
 decodeXmlEntities ($xml)
 
 dump ()
 

Data Fields

 $attributes
 
 $children
 
 $content
 
 $name
 
 $namespaces = array()
 
 $error = null
 
 $use_cdata_section = null
 

Detailed Description

Definition at line 32 of file Node.php.

Member Function Documentation

& addChild (   $child,
  $content = '',
  $attributes = array(),
  $lineno = null,
  $use_cdata_section = null 
)

Append a child node to this node, after all other nodes

Parameters
mixedchild Child to insert (XML_Tree or XML_Tree_Node), or name of child node
stringcontent Content (text) for the new node (only if $child is the node name)
arrayattributes Attribute-hash for new node
Returns
object reference to new child node public

Definition at line 138 of file Node.php.

& cloneNode ( )

Get a copy of this node by clone this node and all of its children, recursively.

Returns
object Reference to the cloned copy. public

Definition at line 170 of file Node.php.

decodeXmlEntities (   $xml)

Decode XML entities in a text string.

Parameters
stringxml Text to decode
Returns
string Decoded text public

Definition at line 562 of file Node.php.

dump ( )

Print text representation of XML_Tree_Node.

public

Definition at line 585 of file Node.php.

encodeXmlEntities (   $xml)

Escape XML entities.

Parameters
stringxml Text string to escape.
Returns
string xml public

Definition at line 520 of file Node.php.

& get (   $use_cdata_section = false)

Returns text representation of this node.

Returns
string text (xml) representation of this node. Each tag is indented according to its level. public

Definition at line 294 of file Node.php.

getAttribute (   $name)

Get an attribute by its name.

Parameters
string$nameName of attribute to retrieve
Returns
string attribute, or null if attribute is unset. public

Definition at line 376 of file Node.php.

& getElement (   $path)

Gets an element by its 'path'.

Parameters
arraypath path to element: sequence of indexes to the children. E.g. array(1, 2, 3) means "third child of second child of first child" of the node.
Returns
object reference to element found, or PEAR_Error if node can't be found. public

Definition at line 444 of file Node.php.

& getNodeAt (   $path)

Get a reference to a node by its 'path'.

Parameters
mixedpath Path to node. Can be either a string (slash-separated children names) or an array (sequence of children names) both starting from this node. The first name in sequence is a child name, not the name of this node.
Returns
object Reference to the XML_Tree_Node found, or PEAR_Error if the path does not match any node. Note that if more than one element matches then only the first matching node is returned. public

Definition at line 480 of file Node.php.

& insertChild (   $path,
  $pos,
$child,
  $content = '',
  $attributes = array() 
)

Inserts child ($child) to a specified child-position ($pos)

Parameters
mixedpath Path to parent node to add child (see getNodeAt() for format). If null child is inserted in the current node.
integerpos Position where to insert the new child. 0 < means |$pos| elements before the end, e.g. -1 appends as last child.
mixedchild Child to insert (XML_Tree or XML_Tree_Node), or name of child node
stringcontent Content (text) for the new node (only if $child is the node name)
arrayattributes Attribute-hash for new node
Returns
Reference to the newly inserted node, or PEAR_Error upon insertion error. public

Definition at line 209 of file Node.php.

registerName (   $name,
  $path 
)

Register a namespace.

Parameters
string$namenamespace
string$pathpath

public

Definition at line 282 of file Node.php.

& removeChild (   $pos)

Removes child at a given position

Parameters
integerpos position of child to remove in children-list. 0 < means |$pos| elements before the end, e.g. -1 removes the last child.
Returns
mixed The removed node, or PEAR_Error upon removal error. public

Definition at line 263 of file Node.php.

setAttribute (   $name,
  $value = '' 
)

Sets an attribute for this node.

Parameters
stringname Name of attribute to set
stringvalue Value of attribute

public

Definition at line 393 of file Node.php.

setContent (   $content,
  $use_cdata_section = null 
)

Sets the content for this node.

Parameters
stringcontent Node content to assign

public

Definition at line 421 of file Node.php.

unsetAttribute (   $name)

Unsets an attribute of this node.

Parameters
string$nameName of attribute to unset

public

Definition at line 406 of file Node.php.

XML_Tree_Node (   $name,
  $content = '',
  $attributes = array(),
  $lineno = null,
  $use_cdata_section = null 
)

Constructor

Parameters
stringname Node name
stringcontent Node content (text)
arrayattributes Attribute-hash for the node

Definition at line 99 of file Node.php.


The documentation for this class was generated from the following file: