PEAR:Config writes wrong XML
| From: | Alexander Czernay | Date: | Fri, 25 Jul 2003 16:08:46 +0000 |
| Subject: | PEAR:Config writes wrong XML | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-6823@lists.php.net to get a copy of this message | ||
I'm trying out the PEAR:Config module with the given examples. I modified the example to write XML rather than phparry to disk.
Looks like this:
<?php
// initialize a Config_Container object
require_once('Config.php');
$conf =& new Config_Container('section', 'conf');
$conf_DB =& $conf->createSection('DB');
$conf_DB->createDirective('type', 'mysql');
$conf_DB->createDirective('host', 'localhost');
$conf_DB->createDirective('user', 'root');
$conf_DB->createDirective('pass', 'root');
// set this container as our root container child in Config
$config = new Config();
$config->setRoot($conf);
// write the container to a php array
$config->writeConfig('config/configuration.xml', 'xml',
array('name' => 'config'));
// print the content of our conf section to screen
echo $conf->toString('xml', array('name' => 'test'));
?>
This produces this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<config>
<?xml version="1.0" encoding="ISO-8859-1"?>
<config>
<DB>
<type>mysql</type>
<host>localhost</host>
<user>root</user>
<pass>root</pass>
</DB>
</config>
</config>
So I wonder if this is just a fault of mine or if there is some bug inside the writer that one could fix.
Thanx for any help,
Alexander