Re: [PHP-XML-DEV] Serializing SimpleXML objects?

[email protected] (Christian Stocker) Fri, 05 Mar 2004 15:33:06 +0100
Newsgroups php.xml.dev
Message-ID <[email protected]>

On 3/5/04 3:26 PM, Philip Fletcher wrote:

>>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)

you can't deserialize XML object like you want. This was discussed before:
http://news.php.net/article.php?group=php.xml.dev&article=205

chregu



> 
> Regards
> 
> Philip
> 

-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [email protected]  |  gnupg-keyid 0x5CE1DECB