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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:03:24+00:00 2026-05-31T21:03:24+00:00

Using simplexml_load_file(), if I’m parsing out XML and I get the following for image…

  • 0

Using simplexml_load_file(), if I’m parsing out XML and I get the following for image…

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [size] => small
        )
    [0] => http://userserve-ak.last.fm/serve/34s/72903330.png
)

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [size] => medium
        )
    [0] => http://userserve-ak.last.fm/serve/64s/72903330.png
) // ... etc

My question is…how do I get to the image URL at array[0]? I know how to access my ‘size’ attribute with the attributes() method. But I can’t seem to echo out the URL. I’ve tried

$img = $xml -> album -> image[0];  <----i see nothing
$img = $xml -> album -> image -> 0;   <-----i get a 500 error

Any help would be greatly appreciated. Thanks!
-Bob

  • 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-31T21:03:26+00:00Added an answer on May 31, 2026 at 9:03 pm
    (string) $xml->album->image;
    

    or

    (string) $xml->album->image[0];
    

    Should do the trick.

    You could also try

    $xml->album->image->asXML();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am parsing an XML feed into a MYSQL table using simplexml_load_file(). Some of
Simple one guys. I have an XML parsed using simplexml_load_file(). The following code: <?php
I'm using this PHP to parse a XML file: <?php $xml = simplexml_load_file(http://api.imgur.com/2/image/zzFV5.xml); echo
I am parsing an xml file using php simplexml_load_file() and then inserting the desired
I am having some problems parsing this piece of XML using SimpleXML. There is
I have an XML file that needs parsing in PHP. I am currenlty using
I'm trying to parse an XML file using PHP, but I get an error
I'm having a problem loading my xml file using simplexml_load_file(), would really appreciate some
I want to parse (little critical) xml using php simplexml...But i can aither get
I'm using PHP's simplexml_load_file to get some data from Flickr. My goal is to

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.