以下代码对于 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/