RSS功能制作
RSS 2.0 规范示例文件中的名称空间
<?xml version="1.0"?>
<!-- RSS generated by Radio UserLand v8.0.5 on 9/30/2002; 4:00:00 AM Pacific -->
<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule">
<channel>
<title>Scripting News</title>
<link>http://www.scripting.com/</link>
<description>A weblog about scripting and stuff like that.</description>
<language>en-us</language>
<blogChannel:blogRoll>
http://radio.weblogs.com/0001015/userland/scriptingNewsLeftLinks.opml
</blogChannel:blogRoll>
<item>
<description>Joshua Allen:
<a href="http://www.netcrucible.com/blog/2002/09/29.html#a243">
Who loves namespaces?</a></description>
<pubDate>Sun, 29 Sep 2002 19:59:01 GMT</pubDate>
<guid>
http://scriptingnews.userland.com/backissues/2002/09/29#When:12:59:01PM
</guid>
</item>
</channel>
</rss>
----------------------------
ASP.NET代码:(注:应该注意时间的问题)
XElement rss = new XElement("rss");
rss.SetAttributeValue("version", "2.0");
XElement channel = new XElement("channel", new XElement[]{
new XElement("title","尹萧风论坛"),
new XElement("link","http://yinxiaofeng.net"),
new XElement("description","尹萧风论坛的最新帖子发布情况"),
});
for (int i = 1; i < 6; i++)
{
XElement item = new XElement("item", new XElement[] {
new XElement("title","帖子"+i),
new XElement("link","http://localhost:15108/"),
new XElement("description","帖子内容"),
new XElement("pubDate",DateTime.UtcNow.ToString("r"))
});
channel.Add(item);
}
rss.Add(channel);
Response.Write(rss.ToString());
Response.End();