A function in my application does the following:
- Capture Web Page using Snoopy
- Load result into DOMDocument
- Load DOMDocument into Simple XML Object
- Run XPath to isolate section of document required
- json_encode the result and save to database for later use.
My problem arises when recovering this block from the database, and decoding it. I can see the @attributes when I var_dump the object, but cannot find a combination of commands that allows me to access them.
Error message is: Fatal error: Cannot use object of type stdClass as array
Below is a sample of my object. I have tried, amongst other what used to work.
echo $obj['class'];
stdClass Object
(
[@attributes] => stdClass Object
(
[class] => race_idx_hdr
)
[img] => stdClass Object
(
[@attributes] => stdClass Object
(
[src] => /Images/Icons/i_blue_bullet.gif
[alt] => image
[title] => United Kingdom
)
)
[a] => Fast Cards
)