I have noticed PEAR XML_Serializer
and XML_Unserializer
are not "reversible", for example :
<?php
$a = array(1, 2);
$serializer = new XML_Serializer();
$serializer->serialize($a);
$b = $serializer->getSerializedData();
print($b); // "<array><XML_Serializer_Tag>1</Xml_Serializer_Tag><XML_Serializer_Tag>2</Xml_Serializer_Tag></array>"
$unserializer = new XML_Unserializer();
$unserializer->unserialize($b);
$c = $unserializer->getUnserializedData();
print_r($c); // array('XML_Serializer_Tag' => array(1, 2)) instead of array(1, 2)
Are there any options for XML_Unserializer
to remove Xml_Serializer_Tag
recursively ?
I found my answer in XML_Unserializer options PEAR Documentation
I modified a line in my code above and it worked :
Too bad this is not the default value...