网页上面都有一个 的标志?为什么这样呢?用来有什么用呢?怎么做呢?好,下面我们就简单的分析一下!站点用来和其他站点之间共享内容的简易方式(也叫聚合内容)。 RSS使用XML作为彼此共享内容的标准方式。用处就不多说了,大家关心的还是怎么做!
首先数据库设计,如图:
好,下面我们开始做页面,我使用的是Repeater控件,代码如下:ReadRss.aspx
<%@ Page language="c#" Codebehind="ReadRss.aspx.cs" AutoEventWireup="false" Inherits="MyTest.rss" ContentType="text/xml" %>
<asp:Repeater id="rptRss" runat="server">
<HeaderTemplate>
<rss version="2.0">
<channel>
<title>rss测试</title>
<link>www.sina.com.cn</link>
<description>这是一个rss的测试</description>
</HeaderTemplate>
<ItemTemplate>
<item>
<title>
<%# FormatForXml(DataBinder.Eval(Container.DataItem,"title"))%>
</title>
<description>
<![CDATA[ <%# FormatForXml(DataBinder.Eval(Container.DataItem,"content"))%>]]>
</description>
<link>
<%# "http://localhost/CompanySystem/shownewsdetails.aspx?newsID="+FormatForXml(DataBinder.Eval(Container.DataItem,"newsID"))%>
</link>
<author><%# FormatForXml(DataBinder.Eval(Container.DataItem,"author"))%></author>
<pubDate><%# FormatForXml(DataBinder.Eval(Container.DataItem,"addTime"))%></pubDate>
<category><%# FormatForXml(DataBinder.Eval(Container.DataItem,"className"))%></category>
</item>
</ItemTemplate>
<FooterTemplate>
</channel></rss>
</FooterTemplate>
</asp:Repeater>
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
BindData();
}
}