#30321 [Opn->Bgs]: serializing a DOMDocument object doesn't work
| From: | derick@php.net | Date: | Mon, 04 Oct 2004 13:47:42 +0000 |
| Subject: | #30321 [Opn->Bgs]: serializing a DOMDocument object doesn't work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-67082@lists.php.net to get a copy of this message | ||
ID: 30321
Updated by: derick@php.net
Reported By: matthias dot hoseit at comline dot de
-Status: Open
+Status: Bogus
Bug Type: DOM XML related
Operating System: Windows 2000, Apache 1.3.31
PHP Version: 5.0.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
.
Previous Comments:
------------------------------------------------------------------------
[2004-10-04 15:32:05] matthias dot hoseit at comline dot de
Description:
------------
The function serialize() doesn't work with a DOMDocument object. After
you've serialized and unserialized an object of DOMDocument the
unserialized object seems to be empty (The object knows that it is a
DOMDocument Object, but all data is lost).
Reproduce code:
---------------
<?PHP
//----------------------------------------------Building a working
DOMDocument-----------------------------------
//create new DOMDocument
$domDoc1 = new DOMDocument();
//create some elements
$rootElement = $domDoc1->createElement("Element1");
$element2 = $domDoc1->createElement("Element2", "Value2");
//adding element to root
$rootElement->appendChild($element2);
//adding root to DOM
$domDoc1->appendChild($rootElement);
//show that DOMDocument is working right now
$elements1 = $domDoc1->getElementsByTagName("Element2");
foreach ($elements1 as $val) {
echo "TagName = '".$val->tagName."' ";
echo "Value = '".$val->nodeValue."'<br>";
}
//----------------------------------------------now the strange
behavior-----------------------------------------
//now serialize DOMObject
$serialize1 = serialize($domDoc1);
//The serialized DOMObject seems to be empty
echo $serialize1."<br>";
//unserialize
$unserialize1 = unserialize($serialize1);
//----------------------------------------------the
error--------------------------------------------------------
//And now there is the error.. $unserialize1 seems to be no
DOMDocument or an empty one
$elements2 = $unserialize1->getElementsByTagName("Element2");
//You get the error message: Warning: Couldn't fetch DOMDocument in
....
//print_r shows an empty object
print_r($unserialize1);
?>
Expected result:
----------------
I thought, when you unserialize a DOMDocument object you get a
DOMDocument object with all data of the original one (NodeLists etc).
Actual result:
--------------
After unserializing a serialized DOMDocument object you get an empty
DOMDocument object.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30321&edit=1