我想在这里解析雅虎天气 rss 提要 xml:http: //developer.yahoo.com/weather/
我的 Rss 项目
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...
}
我的 Rss 经理
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;
}
我不知道,如何解析以下 xml 行:
<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"/>
问题是yweather:<string>
。可能有一篇关于xml解析这样的结构的文章。还是代码示例?
谢谢。