Serializing SimpleXML objects?
| From: | Philip Fletcher | Date: | Fri, 05 Mar 2004 14:26:04 +0000 |
| Subject: | Serializing SimpleXML objects? | ||
| Groups: | php.xml.dev | ||
| Request: | Send a blank email to php-xml-dev+get-346@lists.php.net to get a copy of this message | ||
From the following code snippet, it obviously is, but is it possible to use
them once they're unserialized?
$xml = '<entity1 name="fred">Some Text<entity2 name="bert"
/></entity1>';
$sxml = simplexml_load_string($xml);
echo htmlspecialchars($sxml->asXML());
$ser_xml = serialize($sxml);
//Raises Warning: Node no longer exists in... (twice)
$unser_xml = unserialize($ser_xml);
//Raises Warning: Node no longer exists in... (twice)
echo htmlspecialchars($unser_xml->asXML());
This may seem a strange requirement, but I'm attempting to see if
deserializing has better performance than simplexml_load_file(). (I'm
cacheing portions of a potentially large xml file, so I don't have to load
the whole file for every request)
Regards
Philip