marcus_epik Posted August 9, 2012 Share Posted August 9, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/266878-get-href-from-node-inside-xml/ Share on other sites More sharing options...
requinix Posted August 10, 2012 Share Posted August 10, 2012 You can treat it like it was just HTML: x.href, or the long form x.attributes["href"].value. Quote Link to comment https://forums.phpfreaks.com/topic/266878-get-href-from-node-inside-xml/#findComment-1368259 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.