【问题标题】:Javascript to read remote XML file into array将远程 XML 文件读入数组的 Javascript
【发布时间】:2023-04-05 00:50:01
【问题描述】:

我想根据这个文件创建一个包含 20 首歌曲的艺术家和曲目名称的多维数组。

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

所以我可以创建一个 Spotify 应用程序,生成该列表中前 20 首歌曲的播放列表。

看起来很简单,但我无法接受它。

我会很感激任何帮助,干杯。

【问题讨论】:

    标签: javascript xml arrays spotify playlist


    【解决方案1】:

    您可以使用 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/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-18
      • 2014-12-12
      • 2015-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多