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.
$my_std_class = json_decode(json_encode($my_simplexmlelement)); $my_assoc_array = json_decode(json_encode($my_simplexmlelement), true);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With