RSS文件输出(ASP.NET C#版)

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("    "</span> + title + <span style="COLOR: #a31515">"");

            sb.Append(System.Environment.NewLine);

            sb.Append("    http://www.###.com");

            sb.Append(System.Environment.NewLine);

            sb.Append("    " + title + "");

            sb.Append(System.Environment.NewLine);

            WebBar.BLL.BArticle 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("      <![CDATA["</span>+ae.ArticleTitle+<span style="COLOR: #a31515">"]]>");

                sb.Append(System.Environment.NewLine);

                sb.Append("      http://www.###.com/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 streamwriter = new StreamWriter(fs, Response.ContentEncoding))

                    {

                        streamwriter.Write(sb);

                        Common.JsUtility.Alert("成功生成RSS聚合内容");

                    }

                }

            }

当然:使用JSP,PHP和ASP的朋友也可以用此方法来尝试一下!具体代码我就不贴出来了!

请使用浏览器的分享功能分享到微信等