ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RSS文件输出(ASP.NET C#版)

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

原创 Linux操作系统 作者:iDotNetSpace 时间:2009-10-12 16:49:56 0 删除 编辑

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的朋友也可以用此方法来尝试一下!具体代码我就不贴出来了!

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-616332/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 变量的更多内容
请登录后发表评论 登录
全部评论

注册时间:2008-01-04

  • 博文量
    2376
  • 访问量
    5766208