I want to parse yahoo weather rss feed xml in here : http://developer.yahoo.com/weather/
My Rss Item
public class YahooWeatherRssItem
{
public string Title { get; set; }
public string Link { get; set; }
public string Description { get; set; }
public string City { get; set; }
public string Country { get; set; }
// temp, wind, etc...
}
My Rss Manager
public static IEnumerable<YahooWeatherRssItem> GetYahooWeatherRssItems(string rssUrl)
{
XDocument rssXml = XDocument.Load(rssUrl);
var feeds = from feed in rssXml.Descendants("item")
select new YahooWeatherRssItem
{
I can get following values
Title = feed.Element("title").Value,
Link = feed.Element("link").Value,
Description = feed.Element("description").Value,
// I dont know, How can I parse these.
Text = ?
Temp = ?
Code = ?
};
return feeds;
}
I dont know, How Can I parse following xml lines:
<yweather:condition text="Mostly Cloudy" code="28" temp="50" date="Fri, 18 Dec 2009 9:38 am PST" />
<yweather:location city="Sunnyvale" region="CA" country="United States"/>
<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/>
<yweather:wind chill="50" direction="0" speed="0" />
<yweather:atmosphere humidity="94" visibility="3" pressure="30.27" rising="1" />
<yweather:astronomy sunrise="7:17 am" sunset="4:52 pm"/>
problem is yweather:<string>
. There may be an article about xml parsing like this structure. Or code example?
Thanks.