foreach(DataRow row in ds.Tables[0].Rows)
{
string Id=row["Id"].ToString();
string title=row["title"].ToString();
string description=row["description"].ToString();
string pubdate=row["pubdate"].ToString();
string ClassId=row["ClassId"].ToString();
//string author=row["author"].ToString();
writer.WriteStartElement("item");
writer.WriteStartElement("title");
writer.WriteString(title);
writer.WriteEndElement();
writer.WriteStartElement("link");
writer.WriteString("http://"+Request.ServerVariables["SERVER_NAME"]+"/NewsShow.aspx?ID="+Id) ;
writer.WriteEndElement();
writer.WriteStartElement("description");
writer.WriteCData(description);
writer.WriteEndElement();
writer.WriteStartElement("pubDate");
writer.WriteString(pubdate);
writer.WriteEndElement();
writer.WriteStartElement("category");
writer.WriteString(ClassId);
writer.WriteEndElement();
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.Flush();
writer.Close();
}
2.在线RSS阅读获取。
页面代码:
<P style="FONT-SIZE: 11px">
Feed种子:<asp:TextBox id="FeedUrl" runat="server" Width="440px"></asp:TextBox><BR>
显示条数:<asp:TextBox id="Num" runat="server" Width="48px"></asp:TextBox></P>
<P style="FONT-SIZE: 11px">
<asp:Button id="GetFeed" runat="server" Text="获得RSS"></asp:Button><BR>
<BR>
<asp:Label id="RssFeed" runat="server"></asp:Label></P>
后台代码:
/// <summary>
/// 获得要显示的Feed种子数据
/// </summary>
/// <param name="RssUrl"></param>
/// <param name="showNewsCount"></param>
/// <returns></returns>
public string LoadRSS(string RssUrl, int showNewsCount)
{
string strRssList = "";
& |