RSS フィードを読み取って C# アプリケーションに表示しようとしています。以下のコードを使用しましたが、他の RSS フィードでも完全に機能します。この RSS フィード ---> http://ptwc.weather.gov/ptwc/feeds/ptwc_rss_indian.xmlを読みたいのですが、以下のコードが機能しません。エラーは発生しませんが、何も起こりません。RSS フィードを表示するテキスト ボックスが空です。助けてください。私は何を間違っていますか?
public class RssNews
{
public string Title;
public string PublicationDate;
public string Description;
}
public class RssReader
{
public static List<RssNews> Read(string url)
{
var webResponse = WebRequest.Create(url).GetResponse();
if (webResponse == null)
return null;
var ds = new DataSet();
ds.ReadXml(webResponse.GetResponseStream());
var news = (from row in ds.Tables["item"].AsEnumerable()
select new RssNews
{
Title = row.Field<string>("title"),
PublicationDate = row.Field<string>("pubDate"),
Description = row.Field<string>("description")
}).ToList();
return news;
}
}
private string covertRss(string url)
{
var s = RssReader.Read(url);
StringBuilder sb = new StringBuilder();
foreach (RssNews rs in s)
{
sb.AppendLine(rs.Title);
sb.AppendLine(rs.PublicationDate);
sb.AppendLine(rs.Description);
}
return sb.ToString();
}
//フォームロードコード///
string readableRss;
readableRss = covertRss("http://ptwc.weather.gov/ptwc/feeds/ptwc_rss_indian.xml");
textBox5.Text = readableRss;