Hello All
I'm writing a little app for my personal use and want to store the
configuration data in an xml file. I found PEAR::Config that lets
me read the config data into my app. But so far, I haven't figured
out how to get modifcations back to the xml file.
Here's what I've got so far. I ran across this basic code in an article
at DevShed.
<?php
require_once 'Config.php';
$conf = new Config;
$root =& $conf->parseConfig( '/usr/local/apache/myapp.xml', 'XML');
if (PEAR::isError( $root)) {
die('Error while reading configuration: ' . $root->getMessage() );
}
$settings = $root->toArray();
printf('User settings<br>');
printf('======= ======<br>');
printf('dbhost: %s<br>',$settin gs['root']['connect']['dbhost']);
printf('dbuser: %s<br>',$settin gs['root']['connect']['dbuser']);
printf('dbpass: %s<br>',$settin gs['root']['connect']['dbpass']);
printf('dbname: %s<br>',$settin gs['root']['connect']['dbname']);
$conf->writeConfig( '/usr/local/apache/myapp.xml', 'XML');
?>
What I want to able to do is modify the values in the settings array (not
the problem) and the write them back out to the xml file.
I understand that it takes all the data from the root level and assigns it
to an array called $settings. What I'm having trouble with is getting
$settings back to the file.
Has anyone else used PEAR::Config doing this sort of thing?
Thanks in advance
Charlie Smith
I'm writing a little app for my personal use and want to store the
configuration data in an xml file. I found PEAR::Config that lets
me read the config data into my app. But so far, I haven't figured
out how to get modifcations back to the xml file.
Here's what I've got so far. I ran across this basic code in an article
at DevShed.
<?php
require_once 'Config.php';
$conf = new Config;
$root =& $conf->parseConfig( '/usr/local/apache/myapp.xml', 'XML');
if (PEAR::isError( $root)) {
die('Error while reading configuration: ' . $root->getMessage() );
}
$settings = $root->toArray();
printf('User settings<br>');
printf('======= ======<br>');
printf('dbhost: %s<br>',$settin gs['root']['connect']['dbhost']);
printf('dbuser: %s<br>',$settin gs['root']['connect']['dbuser']);
printf('dbpass: %s<br>',$settin gs['root']['connect']['dbpass']);
printf('dbname: %s<br>',$settin gs['root']['connect']['dbname']);
$conf->writeConfig( '/usr/local/apache/myapp.xml', 'XML');
?>
What I want to able to do is modify the values in the settings array (not
the problem) and the write them back out to the xml file.
I understand that it takes all the data from the root level and assigns it
to an array called $settings. What I'm having trouble with is getting
$settings back to the file.
Has anyone else used PEAR::Config doing this sort of thing?
Thanks in advance
Charlie Smith