【问题标题】:how to convert xml to json using jquery如何使用 jquery 将 xml 转换为 json
【发布时间】:2011-04-08 06:03:52
【问题描述】:

以下代码对于this test XML page 运行良好:

$.get('data/animals.xml', function(xml){
var animals = $.xml2json(xml);
alert(animals.dog[1].name +'/'+ animals.dog[1]);
});

但我怎样才能修改此代码以从this European Central Bank page 获取费率数据?


参考:

【问题讨论】:

    标签: javascript asp.net jquery xml json


    【解决方案1】:

    试试下面的。我已经在 FF 3.6 和 Chrome 6 上对其进行了测试,它可以工作。

    $.get('data/eurofxref-daily.xml', function(xml) {
          var jsonObj = $.xml2json(xml);
          alert(jsonObj.Cube.Cube.Cube[0]["rate"]);
    }); 
    

    【讨论】:

    • 这似乎不起作用:TypeError: jsonObj.Cube is undefined
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-12
    • 2022-01-21
    • 2021-07-22
    • 2019-03-27
    • 1970-01-01
    相关资源
    最近更新 更多