I'm trying to rebuild some stuff I used in python but I'm finding it very tricky to pull data from an API link.
below is the function I'm trying to use to call the API and then get the data I want out of the XML file that the link 'https://api.bmreports.com/BMRS/FUELINSTHHCUR/v1?APIKey=&ServiceType=XML' returns however at the moment I'm struggling to get anything back at all
function GetXML(){
var request = new XMLHttpRequest();
request.open("GET", 'https://api.bmreports.com/BMRS/FUELINSTHHCUR/v1?APIKey=&ServiceType=XML', false);
request.send();
var xml = request.responseXML;
var fuel = xml.getElementsByTagName("fuelType");
for(var i = 0; i < users.length; i++) {
var fuel = fuel[i];
var fuelnames = user.getElementsByTagName("fuelType");
for(var j = 0; j < fuelnames.length; j++) {
alert(fuelnames[j].childNodes[0].nodeValue);
}
}
}