簡體   English   中英

Javascript將遠程XML文件讀入數組

[英]Javascript to read remote XML file into array

我想基於此文件創建一個包含20首歌曲的歌手和曲目名稱的多維數組。

http://ws.audioscrobbler.com/2.0/user/bbc6music/weeklytrackchart.xml

因此,我可以創建一個Spotify應用,該應用生成此列表中前20首歌曲的播放列表。

看起來很簡單,但是我不能跟着它前進。

我將不勝感激,加油。

您可以使用jQuery提取數據並解析數據

$.get("http://ws.audioscrobbler.com/2.0/user/bbc6music/weeklytrackchart.xml",
function(xmlData){
     var $page = $(xmlData);
     //you can now use all the jQuery to conquer the world
     $page.find("track:lt(20)").each(function(){
           var $data = $(this);
           var artistName = $data.find("artist").text();
           //mischief goes here
      });
      //tap the map and say "mischief managed"
 }
);

http://jquery.com/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM