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 7642497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:12:18+00:00 2026-05-31T09:12:18+00:00

When I print_r() the SimpleXMLElement Object referenced by variable $xmlObject , I see the

  • 0

When I print_r() the SimpleXMLElement Object referenced by variable $xmlObject, I see the following structure:

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [uri] => /example
        )

    [result] => SimpleXMLElement Object
        (
            [message] => Record(s) added successfully
            [recorddetail] => Array
                (
                    [0] => SimpleXMLElement Object
                    ...
                )
        )
)

Notice how the $xmlObject->result->message property looks like it is just a string. However, if I do print_r($xmlObject->result->message), I get the following:

SimpleXMLElement Object
(
    [0] => Record(s) added successfully
)

So at this point I’m confused. Why is $xmlObject->result->message being identified as an instance of SimpleXMLElement Object in this case, when the result of printing the full $xmlObject doesn’t suggest this?

And how do I actually access this value? I’ve tried $xmlObject->result->message[0], but it just prints out the same thing (i.e. the last code snippet I posted).

  • 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-31T09:12:20+00:00Added an answer on May 31, 2026 at 9:12 am

    The representation you get when using print_r or var_dump on a SimpleXMLElement has very little to do with how it is structured internally. For instance there is no property @attributes you could access with $element['@attributes']['uri'] either. You just do $element['uri']

    This is simply the way it is. SimpleXmlElement objects behave different. Make sure you read the examples in the PHP Manual before using SimpleXml:

    • http://php.net/manual/en/simplexml.examples-basic.php

    To understand the implementation it in detail, you’d have to look at the source code:

    • http://lxr.php.net/opengrok/xref/PHP_TRUNK/ext/simplexml/simplexml.c

    To print $xmlObject->result->message you just do echo $xmlObject->result->message. That will autocast the SimpleXmlElement to string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have this print output from print_r($theobject); SimpleXMLElement Object ( [@attributes] => Array ( [label]
<?php print_r($response->response->docs); ?> Outputs the following: Array ( [0] => Object ( [_fields:private] =>
When I print_r($var) I get the result below. SimpleXMLElement Object ( [SEND_FILE] => SimpleXMLElement
This is the set of result from my database print_r($plan); Array ( [0] =>
$jj_post is the array output debug via print_r() . This variable is an array
i have printed out the contents of an array/object (named 'document') with print_r. it
I have an array $array1 Array ( [0] => SimpleXMLElement Object ( [galleryid] =>
Array ( [0] => SimpleXMLElement Object ( [record] => SimpleXMLElement Object ( [f] =>
This is the output of print_r() run on a typical SimpleXMLElement object: SimpleXMLElement Object
A print_r of my object ($results) returns the following: QueryResult Object ( [queryLocator] =>

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.