|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-04-26 08:44 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
Description: ------------ I want to cache the object returned by simplexml_load_string() or simplexml_load_file(). Fisrt, I seriaize the object and save it into file. And I read saved string and try to unserialize it. But PHP not handle it collectly. Reproduce code: --------------- <? $data = <<<XML <?xml version='1.0' standalone='yes'?> <movies> <movie> <title>PHP: Behind the Parser</title> </movie> </movies> XML; $xml = simplexml_load_string($data); $str = serialize($xml); echo "$str\n"; $new_xml = unserialize($str); echo serialize($new_xml)."\n"; ?> Expected result: ---------------- O:17:"simplexml_element":1:{s:5:"movie";O:17:"simplexml_element":1:{s:5:"title";s:22:"PHP: Behind the Parser";}} O:17:"simplexml_element":1:{s:5:"movie";O:17:"simplexml_element":1:{s:5:"title";s:22:"PHP: Behind the Parser";}} Actual result: -------------- O:17:"simplexml_element":1:{s:5:"movie";O:17:"simplexml_element":1:{s:5:"title";s:22:"PHP: Behind the Parser";}} Warning: Node no longer exists in /home/gen128/project/mogaha_2004/docs/08_devel/02_research/php-xml/simplexml_performance/test_serialize_xml.php on line 13 Warning: Node no longer exists in /home/gen128/project/mogaha_2004/docs/08_devel/02_research/php-xml/simplexml_performance/test_serialize_xml.php on line 13 Warning: Node no longer exists in /home/gen128/project/mogaha_2004/docs/08_devel/02_research/php-xml/simplexml_performance/test_serialize_xml.php on line 14 O:17:"simplexml_element":0:{}