jQuery - Getting certain tags in XML tree

netfrog

New Member
Let's say I have an \[code\]XML\[/code\] like this: http://ws.audioscrobbler.com/2.0/?m...7b2e0a026&track=Just for Me&artist=Hinoi TeamI want to get the \[code\]<name>\[/code\] inside of the \[code\]<artist>\[/code\] branch. However there are other tags named \[code\]<name>\[/code\] in XML as well. How do i target the one inside \[code\]<artist>\[/code\] specifically?Here's what I am using:\[code\]$.ajax({ type: "GET", url: "http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=b25b959554ed76058ac220b7b2e0a026&track="+yourTrack+"&artist="+yourArtist, dataType: "xml", success: function(xml) { $(".loading").css("display", "none"); $(xml).find('track').each(function(){ var id = $(this).attr('id'); console.log("Success!"); var name = $(this).find('name').text(); $("#more").append("Listing results...\n"); $("#more").append("Name: " + name); }); } });\[/code\]
 
Back
Top