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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:20:04+00:00 2026-05-23T04:20:04+00:00

Array ( [0] => SimpleXMLElement Object ( [record] => SimpleXMLElement Object ( [f] =>

  • 0
Array ( [0] => 
   SimpleXMLElement Object ( [record] => 
   SimpleXMLElement Object ( [f] => 
                             Array ( [0] => Company 
                                     [1] => Company 
                                     [2] => Mark Test 
                                     [3] => Intern 
                                     [4] => Administrative 
                                     [5] => Account 
                                     [6] => img.png 
                                     [7] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 18 ) ) 
                                     [8] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 21 ) ) 
                                     [9] => emailtest@gmail.com 
                                     [10] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 178 ) ) 
                                     [11] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 177 ) ) 
                                     [12] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 179 ) ) 
                                     [13] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 168 ) ) ) 
                            [update_id] => 12102222262043 ) ) )

This is basically my simplexmlobject array that I want to somehow just manipulate and take out the data starting from the f element. I want to store like the words Company, Mark Test, Intern into an array. I can’t seem to figure out how I am suppose to do this with a foreach loop in php and the structure of this is so crazy.

Well to get all the values for this data I did this in part of my code where getUsers() does an api call to a service that gives me a simplexml:

$xml = $getUser->getUsers();
$records = $xml->xpath('//records');

print_r($records);
  • 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-23T04:20:05+00:00Added an answer on May 23, 2026 at 4:20 am

    The DOMDocument class behaves a little better than SimpleXML in cases like this (when you want to do something slightly more complicated)…

    First load the document:

    $dom = new DOMDocument();
    $dom->load($filename);
    

    Then get all the <records> nodes:

    // Get a list of all <records> nodes which you can then loop through with foreach
    $records = $dom->getElementsByTagName('records');
    

    To get the children of all the <records> nodes:

    $allChildren = array();
    foreach ( $records as $recordSet ) {
       foreach( $recordSet->childNodes as $child ) {
         $allChildren[] = $child;
       }
    }
    

    Now lets say you want the value of <first_name> in the first <records> node:

    $value = $records->item(0)->getElementsByTagName('first_name')->item(0)->nodeValue;
    

    Note that the return values from getElementsByTagName are DOMNodeLists not arrays.

    As an added bonus if you know Javascript, this class behaves very much like the DOM is Javascript.

    See also:
    http://www.php.net/manual/en/book.dom.php

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

Sidebar

Related Questions

I have the following XML array: [link]=> array(2) { [0]=> object(SimpleXMLElement)#311 (1) { [@attributes]=>
Here is my XML: [link]=> array(2) { [0]=> object(SimpleXMLElement)#244 (1) { [@attributes]=> array(3) {
Have this print output from print_r($theobject); SimpleXMLElement Object ( [@attributes] => Array ( [label]
I have this SimpleXML object: object(SimpleXMLElement)#176 (1) { [record]=> array(2) { [0]=> object(SimpleXMLElement)#39 (2)
This is an example item: SimpleXMLElement Object ( [@attributes] => Array ( [displayInfoId] =>
SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) [channel] => SimpleXMLElement
SimpleXMLElement Object( [ImageFormat] => SimpleXMLElement Object( [@attributes] => Array( [DimensionCategory] => small [Title] =>
I have an array $array1 Array ( [0] => SimpleXMLElement Object ( [galleryid] =>
I have the following simple xml object file: [AuthorList] => SimpleXMLElement Object ( [@attributes]
How can i, in php access the attributes values: [photos] => SimpleXMLElement Object (

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.