次のRSSフィードがあります。特定の説明タグ内の情報を読みたい。たとえば、タイトルタグが当日で構成されている場合、descriptionタグの情報を取得したいのですが、その方法がわかりません。助けてください
<item>
<title>Forecast for Saturday as of Jul. 14 5:30 AM IST</title> //If today is Saturday get information in description tag
<link>http://www.wunderground.com/global/stations/43466.html</link>
<description>
Thunderstorm. Low:26 &deg; C.
</description>
<pubDate>Sat, 14 Jul 2012 00:00:00 GMT</pubDate>
<guid isPermaLink="false">1342267200-1-night</guid>
</item>
<item>
<title>Forecast for Sunday as of Jul. 14 5:30 AM IST</title>
<link>http://www.wunderground.com/global/stations/43466.html</link>
<description>
Chance of a Thunderstorm. High:30 &deg; C.
</description>
<pubDate>Sat, 14 Jul 2012 00:00:00 GMT</pubDate>
<guid isPermaLink="false">1342353600-2-day</guid>
</item>
私は以下を使用して当日を取得することができました:
string datenow = DateTime.Today.ToString("dddd / M / yyyy");
string[] words= datenow.Split(' ');
string day = words[0];
これは私がRSSフィードを読んでいる方法です:
public class RssReader
{
public static List<RssNews> Read(string url)
{
var webClient = new WebClient();
string result = webClient.DownloadString(url);
XDocument document = XDocument.Parse(result);
return (from descendant in document.Descendants("item")
select new RssNews()
{
Description = descendant.Element("description").Value,
Title = descendant.Element("title").Value,
PublicationDate = descendant.Element("pubDate").Value
}).ToList();
}
}