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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:51:25+00:00 2026-06-03T21:51:25+00:00

I posted something just like this, with no responses but it was because I

  • 0

I posted something just like this, with no responses but it was because I didn’t give enough data. I closed that one and made this one because it better describes. I wasn’t planning on making this.

My code:

 <?php
$q = $_GET['q'];
$xml = simplexml_load_file("http://ws.spotify.com/search/1/track?q=".$q."");

echo $xml->tracks . "<br />";
$num = 0;
foreach($xml->children() as $child){
    $num ++;
    if($num < 5){
        echo "<a href='".$child->attributes(href)."' title=''>".$child->name . " by " . $child->artist->name . "</a><br />";
    }
}

 ?>

I’m trying to call an attirbute of “href” for track.

On Spotify’s website they show:

<?xml version="1.0" encoding="utf-8"?>
<tracks xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1">
  <opensearch:Query role="request" startPage="1" searchTerms="foo"/>
  <opensearch:totalResults>768</opensearch:totalResults>
  <opensearch:startIndex>0</opensearch:startIndex>
  <opensearch:itemsPerPage>100</opensearch:itemsPerPage>
  <track href="spotify:track:3ZsjgLDSvusBgxGWrTAVto">
    <name>The Pretender</name>
    <artist href="spotify:artist:7jy3rLJdDQY21OgRLCZ9sD">
      <name>Foo Fighters</name>
    </artist>
    <id type="isrc">USRW30700007</id>
    <id type="isrc">USRW30700007</id>
    <track-number>1</track-number>
    <length>269.373000</length>
    <popularity>0.79251</popularity>
  </track>
  ...
</tracks>
  • 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-03T21:51:27+00:00Added an answer on June 3, 2026 at 9:51 pm

    Attributes in SimpleXML are very “simple” 😉

    foreach ($xml->children() as $child) {
        ...
        $href = (string)$child['href'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Someone posted something similar but it didn't really solve the problem. I want to
I know that I was already posted similar question but I just can't find
Hi I have just posted something simalar but i have not explained it very
Until recently, I posted Python code (whitespace matters) to blogspot.com using something like this:
This simple problem is kiling me. I posted something earlier about trying to clean
I posted somethign relating to this a few days ago...but I still havent't resolved
i have wizard control with multiple steps. something like this <asp:wizard> <wizardsteps> </wizardsteps> <wizardsteps>
Coming from a c++/make background, I'm used to doing something like this to build
I want something similar to Mysql's sorting of data, but in jquery. I have
I posted a related question to no response but here I'll be less narrow.

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.