News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Make Me Pulse Blog:
Serialize and Unserialize SimpleXML in php
September 28, 2007 @ 09:30:00

From the "Make Me Pulse" blog (of Nicolas Rajabaly & Antoine Ughetto) there's a quick example of how to use serialized values with SimpleXML:

Serialize is useful for storing or passing PHP values around without losing type and structure. But if you want to serialize a SimpleXml object, you will have some problem on unserialize with the error. [...] Replacing SimpleXMLObject with stdClass is a good idea but in this solution we loose all of attributes, and how can we make simplexml->xpath after?

The solution? Serializing the XML content and then outputting it from the SimpleXML object as an XML string (to be stored). This process is reversed when the data is needed back out.

0 comments voice your opinion now!
serialize unserialize simplexml object xml store serialize unserialize simplexml object xml store


blog comments powered by Disqus

Similar Posts

ThinkPHP Blog: Spooky Action at not so much Distance

Brian Moon's Blog: Stupid PHP Tricks: Normalizing SimpleXML Data

Manfred Weber's Blog: Sharing complex objects between PHP and Flash - Part II

James Morris: PHPUnit Mocking and Method Chaining

Alexey Zakhlestin's Blog: Syck 0.9.2


Community Events





Don't see your event here?
Let us know!


version interview tool list podcast conference composer artisanfiles symfony opinion security community language library laravel voicesoftheelephpant series introduction release framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework