Last active
December 17, 2015 12:39
-
-
Save z3bbster/5611424 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//how to convert xml to json using jquery | |
// http://www.fyneworks.com/jquery/xml-to-json/#tab-Usage | |
/* | |
XML File: | |
<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref"> | |
<gesmes:subject>Reference rates</gesmes:subject> | |
<gesmes:Sender> | |
<gesmes:name>European Central Bank</gesmes:name> | |
</gesmes:Sender> | |
<Cube> | |
<Cube time="2013-05-17"> | |
<Cube currency="USD" rate="1.2869"/> | |
<Cube currency="JPY" rate="131.87"/> | |
<Cube currency="BGN" rate="1.9558"/> | |
... | |
</Cube> | |
</Cube> | |
</gesmes:Envelope> | |
*/ | |
$.get('data/eurofxref-daily.xml', function(xml) { | |
var jsonObj = $.xml2json(xml); | |
alert(jsonObj.Cube.Cube.Cube[0]["rate"]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment