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 #370

Numeric arrays in XML files generate Errors

Details

Submitted2003-12-06 13:48 UTC
Fromstrauchdieb at gmx dot de
Assignedmansion
StatusBogus
PackageConfig
PHP Version4.3.3
OSMac OS X
Roadmaps(Not assigned)

Comments

[2003-12-06 13:48 UTC] strauchdieb at gmx dot de

Description:
------------
When I try to read an XML config file I have written with Config I get
an error if the written config arrays contained numeric indexes.

Reproduce code:
---------------
<?
require("Config.php");
$components=array(
"a"=>array("1"=>"a","2"=>"b"),
"b"=>array("99"=>"adc","1"=>"cda")
);
$configObj=new Config;
$root =& $configObj->parseConfig($components, "PHPArray");

$options = array('name' => 'components');
$configObj->writeConfig("components.xml", "XML", $options);

$root =& $configObj->parseConfig("components.xml", "XML");
echo "<pre>"; print_r($root); echo "</pre>";
?>

Expected result:
----------------
Get a ConfigContainer back. Instead, I get a PEAR_Error object.

Actual result:
--------------
xml_parser_error Object
(
[error_message_prefix] => XML_Parser:
[mode] => 1
[level] => 1024
[code] => 4
[message] => not well-formed at XML input line 4
[userinfo] =>
[backtrace] => Array
(
[0] => Array
(
[file] => /usr/local/php/lib/php/XML/Parser.php
[line] => 350
[function] => pear_error
[class] => xml_parser_error
[type] => ->
[args] => Array
(
[0] => not well-formed at XML input line 4
[1] => 4
[2] => 1
[3] => 1024
)

)

[2004-06-04 08:39 UTC] bmansion at mamasam dot com

Just a reminder:

# The first character of an XML tag must be an upper or lower case letter, the underscore, or a colon.
# The remaining characters can be composed of any combination of upper or lower case letters, colons, hyphens, numbers, periods, or underscores.
# XML tags are case sensitive, i.e., <Fish> and <fish> are two different tags.

So your tags are not valid xml.