RSS file output (ASP. NET)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.