Re: Config Packages and XML Error, maybe a bug
| From: | Bertrand Mansion | Date: | Tue, 15 Jul 2003 22:44:29 +0000 |
| Subject: | Re: Config Packages and XML Error, maybe a bug | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-6620@lists.php.net to get a copy of this message | ||
<bmansion@mamasam.com> wrote :
> <angelo@odi.com.br> wrote :
>
>> // set this container as our root container child in Config
>> $config = new Config();
>> $config->setRoot($obj_container);
>> // write the container to a php array
>> $config->writeConfig('config.xml', 'xml');
>> // print the content of our conf section to screen
>>
>> The code to parse
>>
>> $config = new Config();
>> $root
>>
>> =&$config->parseConfig('/home/www/html/plot.odi.com.br/cliente/config.xml',
>> 'xml');
>> var_dump($root);
>>
>>
>> In the begin of the config.xml file it shows <?xml version="1.0"
>> encoding="ISO-8859-1"?>, that does not look right.
>>
>> I'm kida lost. Does anyone have a sugestion?
>
> Jon, Angelo,
>
> Funny, it looks like you both found a bug at the same time. I was able to
> reproduce it, it's probably located in the XML.php file.
>
> I can't fix it now because I need to sleep but as Angelo, you are in Brasil,
> you might find the time to fix it and send me a patch. Otherwise, I'll fix
> that tomorrow and probably add some new methods at the same time before the
> next release.
>
> BTW, it's prefarable not to use var_dump() on Config objects as Containers
> keep references of their parents so you might end up with huge outputs...
>
> Good night,
Sorry, one more thought and I found out what was wrong in your code. Still
I'll see tomorrow if this needs to be fixed or if it is the expected
behaviour as I don't remember.
solution:
Use this:
$config = new Config();
$root =& $config->getRoot();
$root->addItem($obj_container);
Instead of this:
$config = new Config();
$config->setRoot($obj_container);
Because otherwise, you replace the root container by a container that is not
recognised as root.
Bertrand Mansion
Mamasam