Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 378055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:45:22+00:00 2026-05-12T14:45:22+00:00

A function in my application does the following: Capture Web Page using Snoopy Load

  • 0

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
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:45:23+00:00Added an answer on May 12, 2026 at 2:45 pm

    When you decode the json from the database, you get an object of type ‘stdClass’ instead of the original type ‘SimpleXMLElement’ returned by the SimpleXMLElement::xpath function.

    The stdClass object does not ‘know’ about the pseudo array syntax used by SimpleXMLElement objects to allow accessing the attributes.

    Normally you would use the serialize() and unserialize() functions instead of json_encode/decode to store objects in a database, but unfortunately, SimpleXMLElements are not working with those.

    As an alternative, why not just store the actual xml and read it back to SimpleXML after fetching it from the database:

    // convert SimpleXMLElement back to plain xml string
    $xml = $simpleXML->asXML();
    
    // ... code to store $xml in the database
    // ... code to retrieve $xml from database
    
    // recreate SimpleXMLELement
    $simpleXML = simplexml_load_string($xml);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 195k
  • Answers 195k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If I understand you right, you can use this query… May 12, 2026 at 6:59 pm
  • Editorial Team
    Editorial Team added an answer It sounds like this 'dump' program already does what you… May 12, 2026 at 6:59 pm
  • Editorial Team
    Editorial Team added an answer Here's what I ended up going with: <TextBlock Name="ReadUnreadIndicator" Grid.Column="0"… May 12, 2026 at 6:59 pm

Related Questions

Why is it that if I call a seemingly synchronous Windows function like MessageBox()
I am using Web Application Deployment for publishing on IIS. At first I have
I have a page in my application that refreshes some content (a list of
I need to do a sort of timeout or pause in my method for
I have been trying to track down weird problems with my mod_wsgi/Python web application.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.