PEAR::Config
| From: | Paul Scott | Date: | Tue, 15 Jan 2008 17:45:33 +0000 |
| Subject: | PEAR::Config | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-28441@lists.php.net to get a copy of this message | ||
I am trying to use Config to create a file with a number of records in
it as a config file.
The code that I am using is as follows:
$cfile = $this->objConfig->getcontentBasePath().'adm/adm.xml';
if(!file_exists($cfile))
{
$conf =& new Config_Container('section', 'adm');
$conf_serv =& $conf->createSection($servarray['name']);
$conf_serv->createDirective('servername', $servarray['name']);
$conf_serv->createDirective('serverapiurl', $servarray['url']);
$conf_serv->createDirective('serveremail', $servarray['email']);
$conf_serv->createDirective('regtime', date('r'));
$config = new Config();
$config->setRoot($conf);
// write the container to an XML document
$config->writeConfig($cfile, 'XML');
}
else {
// update the xml with the new server (i.e. the file does exist)
$root =& $config->parseConfig($cfile, 'XML', array('name' =>
'adm'));
$conf_serv =& $root->createSection($servarray['name']);
$conf_serv->createDirective('servername', $servarray['name']);
$conf_serv->createDirective('serverapiurl', $servarray['url']);
$conf_serv->createDirective('serveremail', $servarray['email']);
$conf_serv->createDirective('regtime', date('r'));
$config = new Config();
$config->setRoot($root);
// write the container to an XML document
$config->writeConfig($cfile, 'XML');
}
Now, ignoring the objects for the path and things like that, I would
like to get the resulting XML config file to have a section for each
server, all under the root node of <adm />
The closest that I have come so far is to have the 1st server within the
adm tags, and the second as a new root section.
Can anyone help me out here? I have googled this to death and found
almost nothing of use.
TIA
--Paul
--
------------------------------------------------------------.
| Chisimba PHP5 Framework - http://avoir.uwc.ac.za |
:------------------------------------------------------------: