XML_Serializer & references
| From: | darcy w . christ | Date: | Fri, 25 Mar 2005 02:56:48 +0000 |
| Subject: | XML_Serializer & references | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-18318@lists.php.net to get a copy of this message | ||
hi,
i am trying to understand whether i am doing anything wrong or whether there is another approach to my problem.
i have a complex data structure, which includes references.
when i try to serialize that object, XML_Serializer chokes. i've seen this problem before with functions like var_dump(). it's funny to me that print_r() can handle it quite well.
anyway, if anyone can comment on this situation, i would appreciate it. i would simply love to find a way to ignore or identify the references, so that they wouldn't choke.
here's a sample:
require_once 'XML/XML_Serializer/Serializer.php';
$main = array();
$main['test'] = 'green';
$main['blue'] =& $main;
// An array of serializer options
$serializer_options = array (
'addDecl' => TRUE,
'encoding' => 'ISO-8859-1',
'indent' => ' ',
'indentAttributes' => '_auto',
'rootName' => 'SESSION',
'defaultTagName' => 'SESSION',
'typeHints' => TRUE
);
// Instantiate the serializer with the options
$Serializer = &new XML_Serializer($serializer_options);
// Serialize the data structure
$status = $Serializer->serialize($main);
// Check whether serialization worked
if (PEAR::isError($status)) {
die($status->getMessage());
}
// Display the XML document
header('Content-type: text/xml');
echo $Serializer->getSerializedData();
~/darcy w. christ
1000camels