Source for file XML.php
Documentation is available at XML.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Bertrand Mansion <bmansion@mamasam.com> |
// +----------------------------------------------------------------------+
// $Id: XML.php 203592 2005-12-24 02:24:30Z aashley $
require_once('XML/Parser.php');
require_once('XML/Util.php');
* Config parser for XML Files
* @author Bertrand Mansion <bmansion@mamasam.com>
* Deep level used for indentation
* version (1.0) : XML version
* encoding (ISO-8859-1) : XML content encoding
* name : like in phparray, name of your config global entity
* indent : char used for indentation
* linebreak : char used for linebreak
* addDecl : whether to add the xml declaration at beginning or not
* useAttr : whether to use the attributes
* isFile : whether the given content is a file or an XML string
* useCData : whether to surround data with <![CDATA[...]]>
var $options = array ('version' => '1.0',
'encoding' => 'ISO-8859-1',
* @param string $options Options to be used by renderer
* version : (1.0) XML version
* encoding : (ISO-8859-1) XML content encoding
* name : like in phparray, name of your config global entity
* indent : char used for indentation
* linebreak : char used for linebreak
* addDecl : whether to add the xml declaration at beginning or not
* useAttr : whether to use the attributes
* isFile : whether the given content is a file or an XML string
foreach ($options as $key => $value) {
* Parses the data of the given configuration file
* @param string $datasrc path to the configuration file
* @param object $obj reference to a config object
* @return mixed returns a PEAR_ERROR, if error occurs or true if ok
$this->XML_Parser ($this->options['encoding'], 'event');
$err = $this->setInputFile ($datasrc);
if (PEAR ::isError ($err)) {
$err = $this->parseString ($datasrc, true );
$this->setInput ($datasrc);
} // end func parseDatasrc
* Handler for the xml-data
* @param mixed $xp ignored
* @param string $elem name of the element
* @param array $attribs attributes for the generated node
function startHandler ($xp, $elem, &$attribs)
} // end func startHandler
* Handler for the xml-data
* @param mixed $xp ignored
* @param string $elem name of the element
function endHandler ($xp, $elem)
if (count($container->children ) == 0 ) {
$container->setType ('directive');
$container->setContent (trim($this->cdata));
$currentSection->addItem ($container);
* The xml character data handler
* @param mixed $xp ignored
* @param string $data PCDATA between tags
} // end func cdataHandler
* Returns a formatted string of the object
* @param object $obj Container object to be output as string
// Initialize string with xml declaration
$string .= XML_Util ::getXMLDeclaration ($this->options['version'], $this->options['encoding']);
$string .= $this->options['linebreak'];
if (!empty ($this->options['name'])) {
$string .= '<'. $this->options['name']. '>'. $this->options['linebreak'];
$attributes = ($this->options['useAttr']) ? $obj->attributes : array ();
$string .= $indent.XML_Util ::createTag ($obj->name , $attributes, $obj->content , null ,
($this->options['useCData'] ? XML_UTIL_CDATA_SECTION : XML_UTIL_REPLACE_ENTITIES ));
$string .= $this->options['linebreak'];
$string .= $indent. '<!-- '. $obj->content. ' -->';
$string .= $this->options['linebreak'];
$string = $indent. '<'. $obj->name;
$string .= ($this->options['useAttr']) ? XML_Util ::attributesToString ($obj->attributes ) : '';
if ($children = count($obj->children )) {
$string .= '>'. $this->options['linebreak'];
for ($i = 0; $i < $children; $i++ ) {
$string .= $this->toString($obj->getChild ($i));
$string .= $indent. '</'. $obj->name. '>'. $this->options['linebreak'];
$string .= '/>'. $this->options['linebreak'];
if (!empty ($this->options['name'])) {
$string .= '</'. $this->options['name']. '>'. $this->options['linebreak'];
} // end class Config_Container_XML
Documentation generated on Mon, 11 Mar 2019 15:42:05 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|