0

I need to get today rate for CZK currency from European Central Bank XML -> http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml

This is my code now

var xml = $.parseXML("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml"),
$xml = $( xml ),
$test = $xml.find('Cube');

console.log($test.text());

and I got an error Uncaught Error: Invalid XML

Kicker
  • 606
  • 1
  • 12
  • 27

1 Answers1

0

The argument to the parseXml function of JQuery is a string containing the XML document.

So in your example it tries to parse the URL string as XML which apparently fails. To parse the data from the URL load it yourself and then put it into the parseXml function.

wero
  • 32,544
  • 3
  • 59
  • 84
  • But when I tried to do `$.get( "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml", function({ alert( "success" ); })` I got this error `No 'Access-Control-Allow-Origin' header is present on the requested resource.` – Kicker Mar 22 '16 at 16:22
  • @Kicker http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource – wero Mar 22 '16 at 16:25