contenido\classes\class.xmltree.php
Description: XmlTree and XmlNode Class
Requirements:
- Author
- Jan Lengowski
- Con_php_req
- 5.0
- Copyright
- four for business AG
- License
- http://www.contenido.org/license/LIZENZ.txt
- Link
- http://www.4fb.de
- Link
- http://www.contenido.org
- Package
- 4fb_XML
- Since
- file available since contenido release <= 4.6 {@internal created unknown modified 2008-06-30, Dominik Ziegler, add security fix modified 2010-07-03, Ortwin Pinke, removed '=&', causes deprecated runtime error with PHP >= 5.3 $Id: class.xmltree.php 1176 2010-07-03 17:20:34Z oldperl $: }}
- Version
- 1.0.1
\XmlNode
Object of a XML Tree Node
- See
- !! ALWAYS use '=&' with the addRoot and appendChild methods. !!
Properties
Methods


XmlNode(string $strNodeName, string $strNodeContent = '', array $arrNodeAttribs = array(), $cdata = false) : void
Class Constructor
Name | Type | Description |
---|---|---|
$strNodeName | string | XML Node Name |
$strNodeContent | string | XML Node Content |
$arrNodeAttribs | array | Attributes array('name'=>'value') |
$cdata |


_getIndent(int $level) : string
Get indent string
Name | Type | Description |
---|---|---|
$level | int | level |
Type | Description |
---|---|
string | indent string |


_parseAttributes(array $arrAttributes = array()) : string
Builds a string from the attributes array
Name | Type | Description |
---|---|---|
$arrAttributes | array | Attributes array('name'=>'value') |
Type | Description |
---|---|
string | Attribute string |
- Access
- private


add( $strNodeName, $strNodeContent = '', $arrNodeAttribs = array(), $cdata = false) : void
Short for appendChild method
Name | Type | Description |
---|---|---|
$strNodeName | ||
$strNodeContent | ||
$arrNodeAttribs | ||
$cdata |
- See
- \appendChild


addNodeContent(string $strNodeContent) : void
Add content to the node
Name | Type | Description |
---|---|---|
$strNodeContent | string | Content |


appendChild(string $strNodeName, string $strNodeContent = '', array $arrNodeAttribs = array(), bool $cdata = false) : object
Add a child child node
Name | Type | Description |
---|---|---|
$strNodeName | string | XML Node Name |
$strNodeContent | string | XML Node Content |
$arrNodeAttribs | array | Attributes array('name'=>'value') |
$cdata | bool | CDATA Section |
Type | Description |
---|---|
object | Reference to the new node object |


setNodeAttribs(array $arrNodeAttribs) : void
Set the node attributes
Name | Type | Description |
---|---|---|
$arrNodeAttribs | array | Node attributes array('name'=>'value') |


setNodeContent(string $strNodeContent) : void
Set node content
Name | Type | Description |
---|---|---|
$strNodeContent | string | Node content |


setNodeName(string $strNodeName) : void
Set a node name
Name | Type | Description |
---|---|---|
$strNodeName | string | Node name |


setNodeParent(object $objParent) : void
Set the node parent
Name | Type | Description |
---|---|---|
$objParent | object | Reference to the parent object |
\XmlTree
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:
$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
!! ALWAYS use '=&' with the addRoot and appendChild methods. !!
Properties
Methods


XmlTree(string $strXmlVersion = '1.0', string $strXmlEncoding = 'UTF-8') : void
Constructor
Name | Type | Description |
---|---|---|
$strXmlVersion | string | XML Version i.e. "1.0" |
$strXmlEncoding | string | XML Encoding i.e. "UTF-8" |


addRoot(string $strNodeName, string $strNodeContent = '', array $arrNodeAttribs = array()) : object
Add a Root element to the XML Tree
Name | Type | Description |
---|---|---|
$strNodeName | string | XML Node Name |
$strNodeContent | string | XML Node Content |
$arrNodeAttribs | array | Attributes array('name'=>'value') |
Type | Description |
---|---|
object | Reference to the root node object |


dump(boolean $bolReturn = false) : string
Print or Return Tree XML
Name | Type | Description |
---|---|---|
$bolReturn | boolean | Return content |
Type | Description |
---|---|
string | Tree XML |