|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-09-21 15:12 UTC] phpwnd at gmail dot com
[2008-10-16 18:09 UTC] rrichards@php.net
[2011-04-29 13:50 UTC] MartinWillms2000 at aol dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 17:00:01 2025 UTC |
Description: ------------ If you serialize a SimpleXMLElement object, the root-level node is lost, causing the unserialize() event to issue a warning-level error (and creating an empty SimpleXMLElement object) and cause most other SimpleXMLElement methods to fail with a warning-level error. Reproduce code: --------------- <?php $xml = new SimpleXMLElement('<test><foo>1</foo><bar>2</bar></test>'); $serialized = serialize($xml); $unserialized = unserialize($serialized); $unserialized->addChild('testing', 'worked'); echo $unserialized->asXML(); Expected result: ---------------- <?xml version="1.0"?> <test><foo>1</foo><bar>2</bar><testing>worked</testing></test> Actual result: -------------- Warning: unserialize() [function.unserialize]: Node no longer exists in /Applications/MAMP/htdocs/serialxml.php on line 4 Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Node no longer exists in /Applications/MAMP/htdocs/serialxml.php on line 5 Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Cannot add child. Parent is not a permanent member of the XML tree in /Applications/MAMP/htdocs/serialxml.php on line 5 Warning: SimpleXMLElement::asXML() [function.SimpleXMLElement-asXML]: Node no longer exists in /Applications/MAMP/htdocs/serialxml.php on line 6