RSS is changing people's reading habits. At that time, most websites support RSS output. My website (www.web2bar.cn) certainly cannot lag behind. You have written a method to generate the rss2.0 standard file using ASP. NET. I use a file stream to input an XML file. For more information, see the following code:
Stringbuilder sb = new stringbuilder ();
SB. append ("");
SB. append (system. environment. newline );
SB. append (" " );
SB. append (system. environment. newline );
SB. append (" " );
SB. append (system. environment. newline );
SB. append ("");
SB. append (system. environment. newline );
SB. append ("
Http://www.web2bar.cn
");
SB. append (system. environment. newline );
SB. append (" " + Title + "");
SB. append (system. environment. newline );
Webbar. BLL. barticle = new webbar. BLL. barticle ();
Ilist <articleentity> articleentitys = barticle. List (Int. parse (ddlrsscount. selectedvalue. tostring (), Int. parse (ddlchannelid. selectedvalue. tostring ()));
Foreach (articleentity AE in articleentitys)
{
SB. append (" " );
SB. append (system. environment. newline );
SB. append ("");
SB. append (system. environment. newline );
SB. append ("
Http://www.web2bar.cn/Article/ "+ AE. ArticleID. tostring () +". aspx
");
SB. append (system. environment. newline );
SB. append (" + AE. Description + "]> ");
SB. append (system. environment. newline );
SB. append (""+ AE. articleauthor + "");
SB. append (system. environment. newline );
SB. append ("
" + AE. articlecreatetime. tostring ("yyyy-mm-dd hh: mm") +"
");
SB. append (system. environment. newline );
SB. append (" " + AE. commentcount. tostring () + "");
SB. append (system. environment. newline );
SB. append ("");
SB. append (system. environment. newline );
}
SB. append ("");
SB. append (system. environment. newline );
SB. append ("");
Try
{
Using (filestream FS = new filestream (server. mappath (xmlfilename), filemode. Create, fileaccess. Write, fileshare. Write ))
{
Using (streamwriter = new streamwriter (FS, response. contentencoding ))
{
Streamwriter. Write (SB );
Common. jsutility. Alert ("successfully generated RSS aggregate content ");
}
}
}
The generated XML file format is as follows: http://www.web2bar.cn/XML/WebBarRss.xml