Re: Convertig xml into array
| From: | Colin Guthrie | Date: | Tue, 27 Nov 2007 10:11:44 +0000 |
| Subject: | Re: Convertig xml into array | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265059@lists.php.net to get a copy of this message | ||
Edward Kay wrote:
>> -----Original Message-----
>> From: Dave Goodchild [mailto:buddhamagnet@gmail.com]
>> Sent: 27 November 2007 08:36
>> To: PHP General list
>> Subject: [PHP] Convertig xml into array
>>
>>
>> Hi guys. I have the following XML file which I want to convert into a
>> multidimensional array. I am using PHP5 so don't want to use
>> SimpleXML as apparently there are issues with sessions and after
>> conversion I want to pass this array into the session. Any ideas on
>> the best and cleanest way to do this?
>>
>> <snip>
>
> Hi Dave,
>
> The issue with sessions is simply that SimpleXML objects do not persist in
> sessions. To workaround this, just use the asXML() function so your XML is
> stored as a string in the session. You can then recreate the SimpleXML
> object from this string as and when you need it.
You can create a class derived from the SimpleXML objects that implement
__sleep and __wakeup that do this for you transparently.... just make
sure the classes are loaded prior to the session starting (or use autoload)
Col