XML
[ class tree: XML ] [ index: XML ] [ all elements ]

Class: XML_Tree

Source Location: /XML_Tree-2.0.0RC3/XML/Tree.php

Class Overview

XML_Parser
   |
   --XML_Tree

PEAR::XML_Tree


Author(s):

Version:

  • $Version$ - 1.0

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 49]
PEAR::XML_Tree

Purpose

Allows for the building of XML data structures using a tree representation, without the need for an extension like DOMXML.

Example

$tree = new XML_Tree; $root =& $tree->addRoot('root'); $foo =& $root->addChild('foo');

$tree->dump(true);



[ Top ]


Class Variables

$file =  NULL

[line 56]

File Handle

Type:   resource


[ Top ]

$filename =  ''

[line 63]

Filename from which the XML_Tree was read

Type:   string


[ Top ]

$namespace = array()

[line 70]

Namespace

Type:   array


[ Top ]

$root =  NULL

[line 77]

Root node of the XML tree

Type:   object XML_Tree_Node


[ Top ]

$use_cdata_sections =  false

[line 92]

Whether to encapsulate the all CDATA in a <![CDATA[]]> section

Type:   boolean


[ Top ]

$version =  '1.0'

[line 84]

XML Version

Type:   string


[ Top ]



Method Detail

XML_Tree (Constructor)   [line 100]

XML_Tree XML_Tree( [string $filename = ''], [string $version = '1.0'])

Constructor

Parameters:

string   $filename   —  filename Filename where to read the XML
string   $version   —  version XML Version to apply

[ Top ]

addRoot   [line 140]

object XML_Tree_Node &addRoot( string $name, [ $content = ''], [ $attributes = array()], [ $lineno = null])

Sets the root node of the XML tree.
  • Return: Reference to the newly created root node
  • Access: public

Parameters:

string   $name   —  name Name of root element
   $content   — 
   $attributes   — 
   $lineno   — 

[ Top ]

cloneTree   [line 362]

object XML_Tree cloneTree( )

Get a copy of this tree by cloning and all of its nodes, recursively.
  • Return: copy of this node.
  • Access: public

[ Top ]

dump   [line 388]

void dump( [bool $xmlHeader = false])

Print text representation of XML tree.
  • Access: public

Parameters:

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

[ Top ]

get   [line 402]

string &get( )

Get text representation of XML tree.
  • Return: Text (XML) representation of the tree
  • Access: public

[ Top ]

getElementsByTagName   [line 493]

array &getElementsByTagName( string $tagName)

Gets all children that match a given tag name.
  • Return: An array of Node objects of the children found, an empty array if none
  • Author: Pierre-Alain Joye <paj@pearfr.org>
  • Access: public

Parameters:

string   $tagName   —  Tag name

[ Top ]

getElementsByTagNameFromNode   [line 519]

array &getElementsByTagNameFromNode( string $tagName, object &$node)

Gets all children that match a given tag name from node

Parameters:

string   $tagName   —  Tag Name
object   &$node   —  Node in which to search

[ Top ]

getName   [line 423]

string &getName( string $name)

Get current namespace.
  • Access: public

Parameters:

string   $name   —  name namespace

[ Top ]

getNodeAt   [line 460]

object Reference &getNodeAt( mixed $path)

Get a reference to a node. Node is searched by its 'path'.
  • Return: 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.
  • Access: public

Parameters:

mixed   $path   —  path 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.

[ Top ]

getNodeNamespace   [line 431]

void getNodeNamespace( &$node)

Get A Nodes Namespace

Parameters:

   &$node   — 

[ Top ]

getRoot   [line 124]

object Root &getRoot( )

Gets the root node
  • Return: XML_Tree_Node, or PEAR_Error if there isn't any root node.
  • Access: public

[ Top ]

getTreeFromFile   [line 233]

mixed &getTreeFromFile( [string $encoding = null])

Maps a XML file to a XML_Tree
  • Return: The XML tree root (an XML_Tree_Node), or PEAR_Error upon error.
  • Access: public

Parameters:

string   $encoding   —  XML Files encoding, use NULL (default) to use whatever the document specifies

[ Top ]

getTreeFromString   [line 256]

mixed &getTreeFromString( $str, [string $encoding = null])

Maps an XML string to an XML_Tree.
  • Return: The XML tree root (an XML_Tree_Node), or PEAR_Error upon error.
  • Access: public

Parameters:

string   $encoding   —  XML Files encoding, use NULL (default) to use whatever the document specifies
   $str   — 

[ Top ]

insertChild   [line 165]

object Reference &insertChild( mixed $path, integer $pos, mixed $child, [string $content = ''], [array $attributes = array()])

Inserts a child/tree (child) into tree ($path,$pos) and maintains namespace integrity
  • Return: to the inserted child (node), or PEAR_Error upon error
  • See: XML_Tree::getNodeAt()
  • Access: public

Parameters:

mixed   $path   —  path Path to parent node to add child (see getNodeAt() for format)
integer   $pos   —  pos Position where to insert the new child.
  1. < means |$pos| elements before the end,
e.g. -1 appends as last child.
mixed   $child   —  child Child to insert (XML_Tree or XML_Tree_Node), or name of child node
string   $content   —  content Content (text) for the new node (only if $child is the node name)
array   $attributes   —  attributes Attribute-hash for new node

[ Top ]

isValidName   [line 542]

mixed isValidName( string $name, $type)

Checks if $name is a valid XML name

Parameters:

string   $name   —  String to check for validity as an XML Name
   $type   — 

[ Top ]

removeChild   [line 199]

object Parent &removeChild( array $path, integer $pos)

Removes a child node from tree and maintains namespace integrity
  • Return: XML_Tree_Node whose child was removed, or PEAR_Error upon error
  • See: XML_Tree::getNodeAt()
  • Access: public

Parameters:

array   $path   —  path Path to the parent of child to remove (see getNodeAt() for format)
integer   $pos   —  pos Position of child in parent children-list
  1. < means |$pos| elements before the end,
e.g. -1 removes the last child.

[ Top ]

useCdataSections   [line 112]

void useCdataSections( )

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

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:34:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.