PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Configuration » Config » Bug #2013

Problems loading/saving XML

Details

Submitted2004-07-29 13:52 UTC
Fromstephan at wentz dot it
Assignedaashley
StatusClosed
PackageConfig
PHP Version4.3.7
OSLinux
Roadmaps(Not assigned)

Comments

[2004-07-29 13:52 UTC] stephan at wentz dot it

Description:
------------
When I load this empty file with Config and save it again afterwards, the <data></data>-tag isn't being written.

before:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root></root>

after:
<?xml version="1.0" encoding="ISO-8859-1"?>

When I try to load the file again with the same code I get an XML_Parser error.

Shouldn't Config write the empty root-tag?

Reproduce code:
---------------
test.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root></root>

test.php:
<?php
$conf = new Config;
$xml =& $conf->parseConfig('test.xml', 'XML');
$root = $xml->toArray();

$conf = new Config;
$root =& $conf->parseConfig($data, "PHPArray");
$conf->writeConfig('test.xml', "XML");
?>

Expected result:
----------------
test.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root></root>

Actual result:
--------------
test.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>

[2004-08-09 14:30 UTC] phperror at mail dot linkas dot it

Similar to my problem
check it here: http://pear.php.net/bugs/bug.php?id=1877

[2005-04-01 23:52 UTC] ryansking at mac dot com

I'm not able to reproduce this, no matter what I try.

[2005-04-04 09:44 UTC] stephan at wentz dot it

Hmm ok, this seems to be fixed in the latest version.
But let me rephrase this, it's now not really a bug, but an annoying thing:

I have 2 xml-generation variants, one opens an existing xml file, changes it and saves it back, the other get's data from a database and writes it.

Now I need 2 different write-variants to write both cases, but I'd like to do it with one variant.

Reading an XML-File will NOT remove the surrounding Tag, so writing it back with option array('name'=>'data') will lead to this:
<data>
<data>...</data>
<data>

When I write my data i need the name-option so that the surrounding data-tags will be written.

Would be nice if parseConfig('XML',...) would recognize the name-parameter and automatically remove the surrounding tag, so that both cases can be treated the same.

Hope you understand my problem ;-)

[2006-12-06 01:29 UTC] aashley at php dot net

Thank you for your bug report. This issue has been fixed
in the latest released version of the package, which you can download at
http://pear.php.net/get/Config

Please open a new bug about new quirks.