[PHP] Re: How serialize DOMDocument object?

2009-01-19 Thread Nathan Rixham

Михаил Гаврилов wrote:

How serialize DOMDocument object?


describe: serialize — Generates a storable representation of a value
note: It is not possible to serialize PHP built-in objects.
see: http://uk2.php.net/serialize

solve:
$s = DOMDocument-saveXML(); // serialized
DOMDocument-loadXML($s); // unserialize

or if you really want to use serialize function

$s = DOMDocument-saveXML();
serialize($s);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: How serialize DOMDocument object?

2008-12-12 Thread Colin Guthrie

'Twas brillig, and Михаил Гаврилов at 12/12/08 06:23 did gyre and gimble:

How serialize DOMDocument object?


Easiest way is to save it to an XML string and then load it again.

If you want a conveneinet way to store domdocuments in the session, then 
just extend the class and define __sleep and __wakup functions that 
essentially do the save/load for you.


Col


--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php