现在的位置: 首页 > 综合 > 正文

如何发布RSS新闻(附全码)_AX

2013年05月07日 ⁄ 综合 ⁄ 共 2719字 ⁄ 字号 评论关闭

三行代码我弄了两天.......
现给可爱的新人们.
敬请期待如何接收RSS,已经有点眉目了.
【总结】RSS串前面只能已"<?xml****"开始,否则报错,页面部分除第一行外不能有任何内容,否则报错.

【全码】
①页面部分------------把第一行以外的都去掉!
<%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="woall.Test.WebForm3" %>
②后台代码部分
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace woall.Test
{
 /// <summary>
 /// WebForm3 的摘要说明。
 /// </summary>
 public class WebForm3 : System.Web.UI.Page
 {
  private void Page_Load(object sender, System.EventArgs e)
  { 
   //注意:AX字符串这句是在一行里,不能换行.(没试过行不行,估计不能换行,你有兴趣可以试试)
我们的任务就是:根据内容组下面的串,具体怎么组不用我说了吧.如果不会,【附】里面有个很好的例子

   string AX=String.Format("<?xml version=\"1.0\" encoding=\"gb2312\" standalone=\"yes\" ?>   <rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\" xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"> <channel><title>博客园AXzhz最新评论</title>   <link>http://www.cnblogs.com/AXzhz/CommentsRSS.aspx</link>   <description>专注ASP.NET!</description>   <language>zhcn</language>   <pubDate>Mon, 09 Oct 2006 10:23:01 GMT</pubDate>   <lastBuildDate>Mon, 09 Oct 2006 10:23:01 GMT</lastBuildDate>   <generator>cnblogs</generator><item><title>re: 使用脚本控制网页Table的显示隐藏(全代码)_AX</title>   <link>http://www.cnblogs.com/AXzhz/archive/2006/10/07/491675.html#522476</link>   <dc:creator>citymen</dc:creator>   <author>citymen</author>   <pubDate>Sat, 07 Oct 2006 00:58:00 GMT</pubDate>   <guid>http://www.cnblogs.com/AXzhz/archive/2006/10/07/491675.html#522476</guid><description> <![CDATA[ 怎么没有下文了啊 我想知道下文!就是怎么做连接啊,关注ing...<img src =\"http://www.cnblogs.com/AXzhz/aggbug/522476.html\" width = \"1\" height = \"1\" /><br><br><div align=right><a style=\"textdecoration:none;\" href=\"http://AXzhz.cnblogs.com/\" target=\"_blank\">citymen</a> 20061007 08:58 <a href=\"http://www.cnblogs.com/AXzhz/archive/2006/10/07/491675.html#522476#Feedback\" target=\"_blank\" style=\"textdecoration:none;\">发表评论</a></div>  ]]>   </description></item></channel></rss>");   

   Response.ContentType="application/xml";
   Response.Write(AX);

  }
  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);
  }
  #endregion
 }
}

【附】我参考的网址,搜了半天多,唯一一篇有价值的资料.
(弥足珍贵啊,根据我的测试,不能执行,估计作者也没有运行过,很遗憾,被转载的不知道作者了,要不还可以交流一下)
http://www.chinaaspx.com/Comm/Dotnetbbs/Showtopic.aspx?Forum_ID=5&id=151955&PPage=23&Page=1

抱歉!评论已关闭.