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', 'UTF-8'); $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

deprecated 2012-03-03 Use cXmlWriter instead !! 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

 

$_indentChar : string
access private
 

$_objRoot : object
access private
 

$_strRootAttribs : array
access private
 

$_strRootContent : string
access private
 

$_strRootName : string
access private
 

$_strXml : string
access private
 

$_strXmlEncoding : string
access private
 

$_strXmlVersion : string
access private