javascript - 如何使用 jquery 将 xml 转换为 json

标签 javascript asp.net jquery xml json

以下代码对于 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 获取速率数据? ?


引用:

最佳答案

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

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

关于javascript - 如何使用 jquery 将 xml 转换为 json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3642789/

相关文章:

jquery - ASP.NET MVC3 : ValidationType ModelClientValidationRule

javascript - 如何使用 jQuery 动画从上到下滑动不同的 div?

javascript - JS :Want to animate on clicking the button

asp.net - 在 RDLC 报告中添加数据集时 Visual Studio 2013 崩溃

c# - Page_Load() 可以异步吗

asp.net - 如何将下拉列表绑定(bind)到 Dictionary<char, string> 类型的数据源?

jquery - jQuery Mobile 中的多个堆叠页脚(将 div 放在导航栏上方的底部)

javascript - jQuery:.width() 返回 css 设置的百分比,直到窗口调整大小,然后返回像素宽度。为什么?

javascript - window.parent.$() 在 IE 中不起作用

javascript - array.some 和其他在 Nodejs 中不工作