private void wc1_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
//http://xml.weather.yahoo.com/forecastrss?p=NOXX0035&u=c
XDocument doc = new XDocument();
doc = XDocument.Parse(e.Result);
bool forecastTomorrow = true;
foreach (XElement element in doc.Descendants("channel").First().Descendants("item"))
{
if (element.ToString().Contains("Current Conditions"))
{
ContentGrid.Visibility = Visibility.Visible;
string conditions = (string)element.Element("description");
string temp = element.Attribute("temp").Value;
Uri uri = new Uri("Images/" + imageName + ".png", UriKind.Relative);
ImageSource img = new BitmapImage(uri);
imgWeather1.Source = img;
lblCurrent_conditions.Text = HttpUtility.HtmlDecode(arrayConditions[0]) +"\n" + arrayConditions[1] + "\n" + arrayConditions[2] + "\n" + arrayConditions[3] + "\n" + arrayConditions[4];
}
else if (element.ToString().Contains("<yweather:forecast"))
{
;
string day = element.Attribute("day").Value;
string conditions = element.Attribute("text").Value;
string tempLow = element.Attribute("low").Value;
string tempHigh = element.Attribute("high").Value;
string code = element.Attribute("code").Value;
int weatherCode = Convert.ToInt16(code);
string imageName = weatherImage(weatherCode);
Uri uri = new Uri("Images/" + imageName + ".png", UriKind.Relative);
ImageSource img = new BitmapImage(uri);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}