PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » XML » XML_Serializer » Bug #8534

empty string treated like null ?

Details

Request #8534empty string treated like null ?
Submitted2006-08-22 14:53 UTC
Fromgillou_garou at yahoo dot fr
StatusWont fix
PackageXML_Serializer
PHP Version4.4.2
OSlinux
Roadmaps(Not assigned)

Comments

[2006-08-22 14:53 UTC] gillou_garou at yahoo dot fr

Description:
------------
My problem is that an empty string is treated the same way as null value. If i put an empty string as an array value, when serializing with option "cdata", i'd like the serializer to generate an empty cdata tag :
like :
<tag><![CDATA[]]></tag>
instead of just :
<tag />

Test script:
---------------
$tab["tag"]="";

$serializer_options = array (
'addDecl' => TRUE,
'encoding' => 'UTF-8',
'indent' => ' ',
'rootName' => 'root',
'scalarAsAttributes' => FALSE,
'cdata'=> TRUE,
'encodeFunction' => "utf8_encode"
);

$Serializer = &new XML_Serializer($serializer_options);
$Serializer->serialize($tab);
echo($Serializer->getSerializedData());

Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<root>
<tag><![CDATA[]]></tag>
</root>

Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<root>
<tag />
</root>