Home > php教程 > php手册 > C# RSS生成(后台代码)

C# RSS生成(后台代码)

WBOY
Release: 2016-06-06 20:01:40
Original
1179 people have browsed it

前台:就一句话 %@ Page Language="C#" CodeFile="rss.aspx.cs" Inherits="rss" % ----------------------------------------------------------------------------------------------------------------- 后台代码: string strRSS = ""; protected void Page

   前台:就一句话

 

 

-----------------------------------------------------------------------------------------------------------------

 

后台代码:

 

 

 

 string strRSS = "";

    protected void Page_Load(object sender, EventArgs e)
    {
 Response.ContentType = "application/xml"; // 输出并按xml数据显示
 Response.Write(GetRSS());
    }

    ///


    /// 取得聚合文章
    ///

      public string GetRSS()
    {
 //DataSet ds = gr.GenerateRSS(); // 调用GenerateRSS()方法,获得数据
 strRSS = strRSS + "";
 strRSS = strRSS + "";
 strRSS = strRSS + "";
 strRSS = strRSS + "";
 strRSS = strRSS + "学习社区";
 strRSS = strRSS + "http://218.106.183.120/";
 strRSS = strRSS + "Copyright (c) 学习社区";
 strRSS = strRSS + "Latest 20 threads";
 strRSS = strRSS + "Discuz!NT";
 strRSS = strRSS + "Fri, 27 Mar 2009 16:21:08 GMT";
 strRSS = strRSS + "60";
 using (scn = new SqlConnection())
 {
     scn.ConnectionString = "server=.;uid=sa;pwd=111111;database=pubs;";
     scn.Open();
     using (sda = new SqlDataAdapter())
     {
  sda.SelectCommand = scn.CreateCommand();
  sda.SelectCommand.CommandText = "select * from jobs";
  sda.SelectCommand.ExecuteNonQuery();
  DataSet ds = new DataSet();
  sda.Fill(ds);
  if (ds != null && ds.Tables[0].Rows.Count > 0)
  {
      foreach (DataRow dr in ds.Tables[0].Rows)
      {
   strRSS = strRSS + "";
   strRSS = strRSS + "" + dr["job_desc"].ToString().Trim() + "";
   strRSS = strRSS + "http://www.com-edu.cn "; //标题链接
   strRSS = strRSS + "";
   strRSS = strRSS + "土人制造";
   strRSS = strRSS + "" + dr["min_lvl"].ToString().Trim() + "";
   strRSS = strRSS + "http://www.com-edu.cn";  //注释链接
   strRSS = strRSS + "
";
      }
  }
     }
 }
 strRSS = strRSS + "
";
 strRSS = strRSS + "
";

 return strRSS;
    }

 

 

rss2.0参考

    /*
     
 学习社区
 http://218.106.183.120/
 Latest 20 threads
 Copyright (c) 学习社区
 Discuz!NT
 Fri, 27 Mar 2009 16:21:08 GMT
 60
 
   关于北京市高等教育自学考试2009年7月考试报考工作安排的通知
 

    一、注册、报考、缴费时间

    2009年4月15日至25日,逾期不予办理。
    ]]>


   http://218.106.183.120/showtopic-6.aspx
   社区公告
   风中竹影
   Tue, 24 Mar 2009 09:35:00 GMT
 
     
   
    */

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template