:ASP.net RSS購読出力SynciationFeed
3140 ワード
ソースアドレス:http://msdn.microsoft.com/zh-cn/library/system.servicemodel.syndication.syndicationfeed(v=VSL.95).aspx
protected override void OnLoad(EventArgs e)
{
SyndicationFeed feed = new SyndicationFeed(" ", " ", new Uri("http://www.pumaboyd.com/feed"));
Collection<SyndicationItem> items = new Collection<SyndicationItem>();
foreach (var shop in RssData.GetShops())
{
SyndicationItem item = new SyndicationItem();
item.Title = new TextSyndicationContent(shop.ShopName + shop.BranchName);
item.Content = new TextSyndicationContent(shop.Address);
item.Summary = new TextSyndicationContent(shop.Address);
item.Links.Add(new SyndicationLink(new Uri("http://www.pumaboyd.com/shop/" + shop.ShopID)));
item.Authors.Add(new SyndicationPerson("[email protected]",shop.AddUser,"http://www.pumaboyd.com"));
item.PublishDate = shop.AddTime;
item.Id = "http://www.pumaboyd.com/shop/" + shop.ShopID;
items.Add(item);
}
feed.Items = items;
Response.ContentType = "application/rss+xml";
var output = new StringWriter();
var writer = new XmlTextWriter(output);
feed.SaveAsRss20(writer);
Response.Write(output.ToString());
}
:
:http://hi.baidu.com/wuyunju/blog/item/88e6dbdd445a813c5982dd88.html