Jump to content

Get href from node inside xml


marcus_epik

Recommended Posts

hi,

 

I am trying to make a request system for an online radio station. It is going to be Spotify powered. what i want to do is to get the href from this xml line:

 

<track href="spotify:track:76Je5Wklky23mVoxiRszcN">

 

My current code is:

 

<script type="text/javascript">
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","http://ws.spotify.com/search/1/track?q=u mine?",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

var x=xmlDoc.getElementsByTagName("track");
i=0;
function displayrequests()
{
artist=(x[i].getElementsByTagName("name")[1].childNodes[0].nodeValue);
title=(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);
year=(x[i].getElementsByTagName("released")[0].childNodes[0].nodeValue);
txt="<table width='100%' border='1'><tr><td>" + artist + "</td><td>" + title + "</td><td>" + year + "</td></tr></table>";
document.getElementById("showCD").innerHTML=txt;
}

</script><div id="showCD"></div>
<input name="" type="button" value="show requests" onclick="displayrequests()"/>

 

Thanks in advance,

                            Marcus

Link to comment
https://forums.phpfreaks.com/topic/266878-get-href-from-node-inside-xml/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.