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

  • Home
  • SEARCH
  • 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 9258137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:19:11+00:00 2026-06-18T12:19:11+00:00

I have a simpleXML output of: SimpleXMLElement Object ( [@attributes] => Array ( [version]

  • 0

I have a simpleXML output of:

SimpleXMLElement Object
(
    [@attributes] => Array
    (
        [version] => 2
    )
    [currentTime] => 2013-02-05 21:26:09
    [result] => SimpleXMLElement Object
    (
        [rowset] => SimpleXMLElement Object
        (
            [@attributes] => Array
            (
                [name] => characters
                [key] => characterID
                [columns] => name,characterID,corporationName,corporationID
            )
            [row] => Array
            (
                [0] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                    (
                        [name] => Wrytha Cy
                        [characterID] => 209668693
                        [corporationName] => Deep Core Mining Inc.
                        [corporationID] => 1000006
                    )
                )
                [1] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                    (
                        [name] => Eve Mae
                        [characterID] => 624980803
                        [corporationName] => Viziam
                        [corporationID] => 1000066
                    )
                )
                [2] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                    (
                        [name] => Wrytha
                        [characterID] => 709227913
                        [corporationName] => The Flying Tigers
                        [corporationID] => 669350666
                    )
                )
            )
        )
    )
    [cachedUntil] => 2013-02-05 21:35:04
)

I would like to loop through with my php loop and get “name’ and “characterID”. I’ve trying something like:

    $simpleXML = simplexml_load_string($xml); 

    foreach ($simpleXML->result->rowset->row as $row) {
        print_r($row);
        $name = $row['@attributes']['name'];
        echo $name.'<br>';
    }

but $name is not being set. It’s gonna be something simple, just not seeing it in my haste and first time with simpleXML.

  • 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-06-18T12:19:12+00:00Added an answer on June 18, 2026 at 12:19 pm

    Attributes are accessed using the syntax $element['attribute_name'], so in your case, you need $row['name'].

    It’s important to remember that SimpleXML objects are kind of magic – the $element->child, $element_list[0] and $element['foo'] syntax overloads the normal PHP logic to be useful. Similarly, (string)$element will give you the full textual content of an element, however it is broken up in the actual XML.

    As such, the print_r output will not give you a “real” view of the object, so should be used with care. There are a couple of alternative debug functions I’ve written here which give a more accurate idea of how the object will behave.

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

Sidebar

Related Questions

I have this: [1]=> object(SimpleXMLElement)#6 (1) { [@attributes]=> array(14) { [name]=> string(5) MySQL [acknowledged]=>
I have the following simple xml object file: [AuthorList] => SimpleXMLElement Object ( [@attributes]
I have a foreach loop which loops through an array (simpleXML nodes). This array
I have created a simple method used to accept an array of $key=>$value pairs.
I have loaded an XML file using simplexml_load_file($filePath,'SimpleXMLElement', LIBXML_NOCDATA); And for most of the
I have been trying to create an XML using the simplexml library (v2.6.2) http://simple.sourceforge.net/home.php
I'm using a PHP script with SimpleXML to parse an XML feed. I have
I have this simple XML file : <?xml version=1.0 encoding=utf-8 ?> <Artists> <artist artistId=1>
I have an array structure that have to be converted to MXML. I know
I am having trouble on my php simple xml object. I have the following

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.