|
Posted by Werner Elflein on 01/02/06 00:25
Hi!
I tried to use the PEAR class Config.php to parse a XML configuration
file which looks like
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<section>
<item1>value1</item1>
<item2>value2</item2>
<item3>€</item3> <--- EURO sign
</section>
</configuration>
The file has been saved as UTF-8 without signature (BOM). (If a BOM is
used, an error message appears saying, that the XML document is empty.
So that will not be the solution.)
If I use the following PHP script to parse the XML file, a "?" will be
displayed instead of the EURO sign:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<?php
require_once 'Config.php';
$config =& new Config ();
@$root =& $config->parseConfig ('config.xml', 'XML');
if (PEAR::isError ($root))
{
die ('Error while reading configuration: ' . $root->getMessage());
}
$settings = $root->toArray ();
echo ($settings['root']['configuration']['section']['item3']);
?>
</body>
</html>
Replacing the Euro sign by "äöüß", Firefox 1.5 displays four question
marks in a diamond, Internet Explorer two different squares followed by
"/body>".
How can I avoid these errors? Is there a general problem using PEAR
class Config.php???
Kind regards,
Werner
Navigation:
[Reply to this message]
|