contenido\classes\class.xmltree.php

Show: PublicProtectedPrivateinherited
Table of Contents
Project: Contenido Content Management System

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

Package: Default
XmlNode Object

Object of a XML Tree Node

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

Properties

>VPropertypublicarray $_arrNodeAttribs
Node attributes
Details
Type
array
Access
private  
>VPropertypublicboolean $_cdata
Enclose node content in a cdata section
Details
Type
boolean
Access
private  
>VPropertypublicstring $_indentChar
Indenting character
Details
Type
string
>VPropertypublicint $_intChildCount = 0
Child count
Default value0Details
Type
int
Access
private  
>VPropertypublicstring $_strNodeContent
Node content
Details
Type
string
Access
private  
>VPropertypublicstring $_strNodeContentAdded
Added content
Details
Type
string
Access
private  
>VPropertypublicstring $_strNodeName
Node name
Details
Type
string
Access
private  
>VPropertypublicstring $_strXml
XML for this node
Details
Type
string
Access
private  
>VPropertypublicarray $childNodes = array()
Childnodes
Default valuearray()Details
Type
array
Access
private  
>VPropertypublicobject $parentNode = 0
Parent Node
Default value0Details
Type
object

Methods

methodpublicXmlNode(string $strNodeName, string $strNodeContent = '', array $arrNodeAttribs = array(),  $cdata = false) : void

Class Constructor

Parameters
NameTypeDescription
$strNodeNamestring

XML Node Name

$strNodeContentstring

XML Node Content

$arrNodeAttribsarray

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

$cdata
methodpublic_getIndent(int $level) : string

Get indent string

Parameters
NameTypeDescription
$levelint

level

Returns
TypeDescription
stringindent string
methodpublic_parseAttributes(array $arrAttributes = array()) : string

Builds a string from the attributes array

Parameters
NameTypeDescription
$arrAttributesarray

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

Returns
TypeDescription
stringAttribute string
Details
Access
private  
methodpublicadd( $strNodeName,  $strNodeContent = '',  $arrNodeAttribs = array(),  $cdata = false) : void

Short for appendChild method

Parameters
NameTypeDescription
$strNodeName
$strNodeContent
$arrNodeAttribs
$cdata
Details
See
\appendChild  
methodpublicaddNodeContent(string $strNodeContent) : void

Add content to the node

Parameters
NameTypeDescription
$strNodeContentstring

Content

methodpublicappendChild(string $strNodeName, string $strNodeContent = '', array $arrNodeAttribs = array(), bool $cdata = false) : object

Add a child child node

Parameters
NameTypeDescription
$strNodeNamestring

XML Node Name

$strNodeContentstring

XML Node Content

$arrNodeAttribsarray

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

$cdatabool

CDATA Section

Returns
TypeDescription
objectReference to the new node object
methodpublichasChilds() : boolean

Check if the node has childs

Returns
TypeDescription
boolean
methodpublicsetIndent(int $string = "") : void

Set the indent string

Parameters
NameTypeDescription
$stringint

level

methodpublicsetNodeAttribs(array $arrNodeAttribs) : void

Set the node attributes

Parameters
NameTypeDescription
$arrNodeAttribsarray

Node attributes array('name'=>'value')

methodpublicsetNodeContent(string $strNodeContent) : void

Set node content

Parameters
NameTypeDescription
$strNodeContentstring

Node content

methodpublicsetNodeName(string $strNodeName) : void

Set a node name

Parameters
NameTypeDescription
$strNodeNamestring

Node name

methodpublicsetNodeParent(object $objParent) : void

Set the node parent

Parameters
NameTypeDescription
$objParentobject

Reference to the parent object

methodpublictoXml( $indent = 0) : string

Builds the XML string for the node using the node properties

Parameters
NameTypeDescription
$indent
Returns
TypeDescription
stringXML String
Details
Access
private  

\XmlTree

Package: Default
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. !!

Properties

>VPropertypublicstring $_indentChar = ""
Indent character
Default value""Details
Type
string
Access
private  
>VPropertypublicobject $_objRoot
Root node
Details
Type
object
Access
private  
>VPropertypublicarray $_strRootAttribs
Root attributes
Details
Type
array
Access
private  
>VPropertypublicstring $_strRootContent
Root content
Details
Type
string
Access
private  
>VPropertypublicstring $_strRootName
Root element name
Details
Type
string
Access
private  
>VPropertypublicstring $_strXml
Tree XML string
Details
Type
string
Access
private  
>VPropertypublicstring $_strXmlEncoding
XML Encoding string
Details
Type
string
Access
private  
>VPropertypublicstring $_strXmlVersion
XML Version string
Details
Type
string
Access
private  

Methods

methodpublicXmlTree(string $strXmlVersion = '1.0', string $strXmlEncoding = 'UTF-8') : void

Constructor

Parameters
NameTypeDescription
$strXmlVersionstring

XML Version i.e. "1.0"

$strXmlEncodingstring

XML Encoding i.e. "UTF-8"

methodpublicaddRoot(string $strNodeName, string $strNodeContent = '', array $arrNodeAttribs = array()) : object

Add a Root element to the XML Tree

Parameters
NameTypeDescription
$strNodeNamestring

XML Node Name

$strNodeContentstring

XML Node Content

$arrNodeAttribsarray

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

Returns
TypeDescription
objectReference to the root node object
methodpublicdump(boolean $bolReturn = false) : string

Print or Return Tree XML

Parameters
NameTypeDescription
$bolReturnboolean

Return content

Returns
TypeDescription
stringTree XML
methodpublicsetIndent(int $string) : void

Set the indent string

Parameters
NameTypeDescription
$stringint

level

Documentation was generated by phpDocumentor 2.0.0a12.