Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
XML_Tree Class Reference
Inheritance diagram for XML_Tree:

Public Member Functions

 XML_Tree ($filename= '', $version= '1.0')
 
 useCdataSections ()
 
getRoot ()
 
addRoot ($name, $content= '', $attributes=array(), $lineno=null)
 
insertChild ($path, $pos, $child, $content= '', $attributes=array())
 
removeChild ($path, $pos)
 
getTreeFromFile ()
 
getTreeFromString ($str)
 
 startHandler ($xp, $elem, &$attribs)
 
 endHandler ($xp, $elem)
 
 cdataHandler ($xp, $data)
 
 cloneTree ()
 
 dump ($xmlHeader=false)
 
get ()
 
getName ($name)
 
 getNodeNamespace (&$node)
 
getNodeAt ($path)
 
getElementsByTagName ($tagName)
 
getElementsByTagNameFromNode ($tagName, &$node)
 

Static Public Member Functions

 isValidName ($name, $type)
 

Data Fields

 $file = NULL
 
 $filename = ''
 
 $namespace = array()
 
 $root = NULL
 
 $version = '1.0'
 
 $use_cdata_sections = false
 

Detailed Description

Definition at line 51 of file Tree.php.

Member Function Documentation

& addRoot (   $name,
  $content = '',
  $attributes = array(),
  $lineno = null 
)

Sets the root node of the XML tree.

Parameters
stringname Name of root element
Returns
object XML_Tree_Node Reference to the newly created root node public

Definition at line 142 of file Tree.php.

cdataHandler (   $xp,
  $data 
)

The xml character data handler Used by XML_Parser::XML_Parser() when parsing an XML stream.

Parameters
mixedxp ignored
stringdata PCDATA between tags

private

Definition at line 356 of file Tree.php.

cloneTree ( )

Get a copy of this tree by cloning and all of its nodes, recursively.

Returns
object XML_Tree copy of this node. public

Definition at line 367 of file Tree.php.

dump (   $xmlHeader = false)

Print text representation of XML tree.

Parameters
boolxmlHeader if true then generate also the leading XML 'Content-type' header directive, e.g. for direct output to a web page.

public

Definition at line 393 of file Tree.php.

endHandler (   $xp,
  $elem 
)

Handler for the xml-data Used by XML_Parser::XML_Parser() when parsing an XML stream.

Parameters
mixedxp ignored
stringelem name of the element

private

Definition at line 314 of file Tree.php.

& get ( )

Get text representation of XML tree.

Returns
string Text (XML) representation of the tree public

Definition at line 407 of file Tree.php.

& getElementsByTagName (   $tagName)

Gets all children that match a given tag name.

Parameters
stringTag name
Returns
array An array of Node objects of the children found, an empty array if none public
Author
Pierre-Alain Joye paj@p.nosp@m.earf.nosp@m.r.org

Definition at line 498 of file Tree.php.

& getElementsByTagNameFromNode (   $tagName,
$node 
)

Gets all children that match a given tag name from node

Parameters
string$tagNameTag Name
object&$nodeNode in which to search
See Also
XML_Tree::getElementsByTagName()
Returns
array An array of found Node objects, empty is none found. public
Author
Pierre-Alain Joye paj@p.nosp@m.earf.nosp@m.r.org
Davey Shafik davey.nosp@m.@php.nosp@m..net

Definition at line 524 of file Tree.php.

& getName (   $name)

Get current namespace.

Parameters
stringname namespace
Returns
string

public

Definition at line 428 of file Tree.php.

& getNodeAt (   $path)

Get a reference to a node. Node is searched 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 of them starting from node. Note that the first name in sequence must be the name of the document root.
Returns
object Reference to the XML_Tree_Node found, or PEAR_Error if the path does not exist. If more than one element matches then only the first match is returned. public

Definition at line 465 of file Tree.php.

getNodeNamespace ( $node)

Get A Nodes Namespace

Definition at line 436 of file Tree.php.

& getRoot ( )

Gets the root node

Returns
object Root XML_Tree_Node, or PEAR_Error if there isn't any root node.

public

Definition at line 126 of file Tree.php.

& getTreeFromFile ( )

Maps a XML file to a XML_Tree

Returns
mixed The XML tree root (an XML_Tree_Node), or PEAR_Error upon error. public

Definition at line 234 of file Tree.php.

& getTreeFromString (   $str)

Maps an XML string to an XML_Tree.

Returns
mixed The XML tree root (an XML_Tree_Node), or PEAR_Error upon error. public

Definition at line 256 of file Tree.php.

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

Inserts a child/tree (child) into tree ($path,$pos) and maintains namespace integrity

Parameters
mixedpath Path to parent node to add child (see getNodeAt() for format)
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
object Reference to the inserted child (node), or PEAR_Error upon error public
See Also
getNodeAt()

Definition at line 167 of file Tree.php.

isValidName (   $name,
  $type 
)
static

Checks if $name is a valid XML name

Parameters
string$nameString to check for validity as an XML Name
Returns
mixed

Definition at line 547 of file Tree.php.

& removeChild (   $path,
  $pos 
)

Removes a child node from tree and maintains namespace integrity

Parameters
arraypath Path to the parent of child to remove (see getNodeAt() for format)
integerpos Position of child in parent children-list 0 < means |$pos| elements before the end, e.g. -1 removes the last child.
Returns
object Parent XML_Tree_Node whose child was removed, or PEAR_Error upon error public
See Also
getNodeAt()

Definition at line 201 of file Tree.php.

startHandler (   $xp,
  $elem,
$attribs 
)

Handler for the xml-data Used by XML_Parser::XML_Parser() when parsing an XML stream.

Parameters
mixedxp ignored
stringelem name of the element
arrayattribs attributes for the generated node

private

Definition at line 279 of file Tree.php.

useCdataSections ( )

Use <![CDATA[]]> for all CDATA sections

Returns
void

Definition at line 114 of file Tree.php.

XML_Tree (   $filename = '',
  $version = '1.0' 
)

Constructor

Parameters
stringfilename Filename where to read the XML
stringversion XML Version to apply

Definition at line 102 of file Tree.php.


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