I want to get some data from a freely accessible XML file on a remote server.
These are AEMET Open Data files. The idea is to read the xml and extract some information. I want to do it using javascript, so that I can display this data obtained from the xml file on a website. As an example one of the files is;
http://www.aemet.es/xml/maritima/FQXX46MM.xml
I understand how to do it in Python; I create a variable with the content of the XML and then with BeautifulSoup or any other scrapper I read the DOM data from the xml. I have no idea how to get started in javascript. How do I read the remote xml? from there I think I understand how I can get the data of each label.
I have searched how to do it and everything I find seems to be oriented to Ajax, but I can't find how to do it by reading the remote xml directly.
You can specify the
dataType
name of jQuery's $.ajax function as "xml"Example
Unfortunately, as the comment indicates, the particular resource you are trying to access: http://www.aemet.es/xml/maritima/FQXX46MM.xml does not deliver the header in the response,
"Access-Control-Allow-Origin"
so the browser will block the request showing the following message (in Chrome):So, at least that particular file won't be readable from JavaScript, unless that page lists the domain where your script is hosted as allowed.