Skip to content

Instantly share code, notes, and snippets.

@markis
Created February 20, 2014 07:17
Show Gist options
  • Save markis/9108499 to your computer and use it in GitHub Desktop.
Save markis/9108499 to your computer and use it in GitHub Desktop.
var stops=[];
$.ajax({
url:"http://webservices.nextbus.com/service/publicXMLFeed?command=predictionsForMultiStops&a=sf-muni&stops=37|4169&stops=37|3255&stops=48|3476&stops=48|4924",
success:function(xml) {
$("predictions", xml).each(function(idx, predictions) {
var stop = {times:[]};
$.each(predictions.attributes, function(idx, attribute) { stop[attribute.name] = attribute.value });
$("prediction", predictions).each(function(idx, prediction) {
var time = {};
$.each(prediction.attributes, function(idx, attribute) { time[attribute.name] = parseInt(attribute.value) ? parseInt(attribute.value) : attribute.value });
stop.times.push(time);
});
stops.push(stop);
});
console.log(stops);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment