tags:

views:

158

answers:

2

Does anybody know a quick way to convert a SimpleXMLElement to a normal STDClass object, without iterating through each branch manually? I would feel better working with a normal object after fetching the data.

+2  A: 

I don't know if there's a way to convert the object without iterating through it. My guess is that you can't.

You can check this thread out, it shows you how to convert a SimpleXML to an array, you can adapt that.

Alex Ciminian
+2  A: 

I suggest looking into using XMLReader, which lends itself well to extracting data and storing it as whatever data type one wishes, instead of SimpleXML. It's especially good for regularly-used documents (I use it, extended as RSSReader, for RSS), is much faster than might be expected, and as a bonus uses less memory than SimpleXML.

GZipp
Thanks GZipp, I will look into that.
Pekka