//Load up the Stops For the selected Route Class async private Task <vehicleLocation> loadXML_vehicleLocations(Uri uri) { vehicleLocation vehicleLocation = new vehicleLocation(); try { var client = new HttpClient(); var stream = await client.GetStreamAsync(uri); XmlReader reader = XmlReader.Create(stream); //reader.ReadToFollowing("vehicle"); while (reader.Read()) { Debug.WriteLine("Name: " + reader.Name); if (reader.NodeType == XmlNodeType.Element) { if (reader.HasAttributes && reader.Name == "vehicle") { vehicleLocation.latitude = reader.GetAttribute("latitude"); vehicleLocation.longitude = reader.GetAttribute("longitude"); } } } } catch (Exception ex) { //routeList = "EXCEPTION"; } return(vehicleLocation); }
public void loadLocationInfo(string vehicleID) { Debug.WriteLine("NSP Dir Selected: " + vehicleID); string urlString_stopInfo = "http://developer.trimet.org/ws/v2/vehicles/json/false/ids/" + vehicleID + "/appID/7BCBE4BB29666DDCBB7D73113"; Uri uri_stops = new Uri(urlString_stopInfo); Task <vehicleLocation> returnLocationInfoTask = Task.Run(() => loadXML_vehicleLocations(uri_stops)); vehicleLocation = returnLocationInfoTask.Result; }