XmlTree class

Class to create XML tree structures from scratch without the need for a XML DOM

Example:

!! Attention, using '=&' is deprecated in PHP >= 5.3 and causes a deprecated runtime error don't use it any more (Ortwin Pinke, 2010-07-03

$tree = new XmlTree('1.0', 'ISO-8859-1'); $root =& $tree->addRoot('rootname', 'some content', array('foo'=>'bar'));

This genererates following XML:

some content

$root now references the 'rootname' node object. To append childNodes use the appendChild method.

$foo =& $root->appendChild('foo', 'bar');

Note: From version 1.1 you can use the $obj->add() method as shortcut to appendchild

some contentbar

!! ALWAYS use '=&' with the addRoot and appendChild methods. !!

 Methods

Constructor

XmlTree(string $strXmlVersion, string $strXmlEncoding) : void

Parameters

$strXmlVersion

string

XML Version i.e. "1.0"

$strXmlEncoding

string

XML Encoding i.e. "UTF-8"

Add a Root element to the XML Tree

addRoot(string $strNodeName, string $strNodeContent, array $arrNodeAttribs) : object

Parameters

$strNodeName

string

XML Node Name

$strNodeContent

string

XML Node Content

$arrNodeAttribs

array

Attributes array('name'=>'value')

Returns

objectReference to the root node object

Print or Return Tree XML

dump(boolean $bolReturn) : string

Parameters

$bolReturn

boolean

Return content

Returns

stringTree XML

Set the indent string

setIndent(int $string) : void

Parameters

$string

int

level

 Properties

 

Indent character

$_indentChar : string

access private
 

Root node

$_objRoot : object

access private
 

Root attributes

$_strRootAttribs : array

access private
 

Root content

$_strRootContent : string

access private
 

Root element name

$_strRootName : string

access private
 

Tree XML string

$_strXml : string

access private
 

XML Encoding string

$_strXmlEncoding : string

access private
 

XML Version string

$_strXmlVersion : string

access private