The following code runs very well for this test XML page:
下面的代码在这个测试XML页面上运行得非常好:
$.get('data/animals.xml', function(xml){
var animals = $.xml2json(xml);
alert(animals.dog[1].name +'/'+ animals.dog[1]);
});
But how can I adapt this code to get the rate data from this European Central Bank page?
但我如何修改这段代码,从欧洲央行的页面获取利率数据呢?
Reference:
参考:
- http://www.fyneworks.com/jquery/xml-to-json/#tab-Usage
- http://www.fyneworks.com/jquery/xml-to-json/ tab-Usage
- getting data using javascript
- 获取数据使用javascript
1 个解决方案
#1
12
Try the following. I've tested it on FF 3.6 and Chrome 6, it works.
试试下面的。我已经在FF 3.6和Chrome 6上测试过,它是有效的。
$.get('data/eurofxref-daily.xml', function(xml) {
var jsonObj = $.xml2json(xml);
alert(jsonObj.Cube.Cube.Cube[0]["rate"]);
});
#1
12
Try the following. I've tested it on FF 3.6 and Chrome 6, it works.
试试下面的。我已经在FF 3.6和Chrome 6上测试过,它是有效的。
$.get('data/eurofxref-daily.xml', function(xml) {
var jsonObj = $.xml2json(xml);
alert(jsonObj.Cube.Cube.Cube[0]["rate"]);
});