PEAR Unserializer and the &
Posted: Thu Feb 24, 2011 2:43 pm
Hi,
I try to use the PEAR Unserializer (http://pear.php.net/manual/en/package.x ... alizer.php) to convert XML into an array. It works fine but the & disapears (see below). Does anyone know why? I will not work with an other tool because it works fine in a large system.
Thanks a lot!
burpy
I try to use the PEAR Unserializer (http://pear.php.net/manual/en/package.x ... alizer.php) to convert XML into an array. It works fine but the & disapears (see below). Does anyone know why? I will not work with an other tool because it works fine in a large system.
Thanks a lot!
burpy
Code: Select all
<?php
require('XML/Unserializer.php');
$unserializer_options = array (
'mode' => 'simplexml',
'scalarAsAttributes' => false,
'attributesArray' => '_attributes',
'contentName' => '_content',
'targetEncoding' => 'iso-8859-1',
'parseAttributes' => true);
$XML_unserializer = &new XML_Unserializer($unserializer_options);
$xml = '<?xml version="1.0" encoding="iso-8859-1" ?>
<product>
<name>Abercrombie & Fitch</name>
</product>';
//Unserialize the XML data structure
$products = $XML_unserializer->unserialize($xml, false);
//Check whether unserialization of XML worked
if(PEAR::isError($products)){
die($products->getMessage());
}
//Get unserialized data
$feed = $XML_unserializer->getUnserializedData();
echo "<pre>";
print_r($feed);
echo "</pre>";