如何使用jquery将xml转换为json

以下代码对此测试XML页面运行良好:

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

但是,我如何调整此代码以从此欧洲中央银行页面获取费率数据?

参考:

  • http://www.fyneworks.com/jquery/xml-to-json/#tab-Usage
  • 使用javascript获取数据

请尝试以下方法。 我在FF 3.6和Chrome 6上测试了它,它的工作原理。

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