用输出的jquery问题解析xml

时间:2009-09-17 06:47:16

标签: jquery html xml

我想用jquery解析一个xml文件。到目前为止,只有输出混淆了我:) 可能你可以帮助我。

$(function(){
  $.get("images.xml",{},function(xml){
    var output = "<ul>";

    $(xml).each(function() {
      smallImage = $(this).find("small").text();
      //bigImage = $(this).find("big").text();

      output += "<li>" + smallImage + "</li>";
      output += "</ul>";
    });

    $("#wrapper").append(output);
  });
});

我希望将每个图像链接放在一个单独的行中,直到现在所有链接都在一起。 谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

将get请求的类型也设为xml;

$(function(){
    $.get("images.xml",{},function(xml){
        var output = "<ul>";
        $(xml).each(function() {
        smallImage = $(this).find("small").text();
        //bigImage = $(this).find("big").text();
        output += "<li>" + smallImage + "</li>";
        output += "</ul>";
    });
    $("#wrapper").append(output);
} ,'xml');
});