Page 1 of 1

PEAR Unserializer and the &

Posted: Thu Feb 24, 2011 2:43 pm
by burpy
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

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>";


Re: PEAR Unserializer and the &amp;

Posted: Thu Feb 24, 2011 3:12 pm
by Weirdan
Post the output of this script, but please use

Code: Select all

echo htmlspecialchars(var_export($feed, true));
instead of print_r()

Re: PEAR Unserializer and the &amp;

Posted: Fri Feb 25, 2011 6:46 am
by burpy
no this doesn't help. The output is the same:
array (
'name' => 'Abercrombie Fitch',
)

The & disappears!

Re: PEAR Unserializer and the &amp;

Posted: Fri Feb 25, 2011 8:50 am
by Weirdan
http://pear.php.net/bugs/bug.php?id=16153 - seems to be exactly your issue