Skip to content

Instantly share code, notes, and snippets.

@defeated
Created August 9, 2009 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defeated/164797 to your computer and use it in GitHub Desktop.
Save defeated/164797 to your computer and use it in GitHub Desktop.
private string GetTemperatureViaHTTPGET() {
var results = string.Empty;
var url = "http://ws.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP?ZIP=" + zipcode.Text;
using(var web = new WebClient())
using(var stream = web.OpenRead(new Uri(url)))
using(var reader = new StreamReader(stream)) {
results = reader.ReadToEnd();
}
var xml = XDocument.Parse(results);
var ns = xml.Root.Name.NamespaceName;
return xml.Root.Element(XName.Get("Temperature", ns)).Value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment