国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識(shí)百科 - 正文

asp.net(c#) RSS功能實(shí)現(xiàn)代碼

來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 22:44:47
文檔

asp.net(c#) RSS功能實(shí)現(xiàn)代碼

asp.net(c#) RSS功能實(shí)現(xiàn)代碼:可能還有很多未完善,但終歸可以使用了,以后再慢慢改進(jìn)。 以下是我RSS界面的后臺(tái)代碼,給需要的朋友提供下我的經(jīng)驗(yàn): 代碼如下:using System; using System.Data; using System.Configuration; using System.Collections; us
推薦度:
導(dǎo)讀asp.net(c#) RSS功能實(shí)現(xiàn)代碼:可能還有很多未完善,但終歸可以使用了,以后再慢慢改進(jìn)。 以下是我RSS界面的后臺(tái)代碼,給需要的朋友提供下我的經(jīng)驗(yàn): 代碼如下:using System; using System.Data; using System.Configuration; using System.Collections; us

可能還有很多未完善,但終歸可以使用了,以后再慢慢改進(jìn)!!  
以下是我RSS界面的后臺(tái)代碼,給需要的朋友提供下我的經(jīng)驗(yàn):  
代碼如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.IO;
using System.Web.Configuration;
public partial class rss : System.Web.UI.Page
{
    string   HostUrl; 
    string   HttpHead;
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpContext context = HttpContext.Current;
        HostUrl = context.Request.Url.ToString();
        HostUrl = HostUrl.Substring(0, HostUrl.IndexOf("/", 8));
        XmlTextWriter writer = new XmlTextWriter(context.Response.OutputStream, System.Text.Encoding.UTF8);
        WriteRSSPrologue(writer);
        WriteRSSHeadChennel(writer);
        string sql = "select top 10 title,id,time,content from blog_title order by time desc";
        SqlDataReader dr = dbconn.ExecuteReader(sql);
        while (dr.Read())
        {
            AddRSSItem(writer, (((DateTime)dr["time"]).ToUniversalTime()).ToString("r"), dr["title"].ToString(), HostUrl, dr["content"].ToString());
        }
        dr.Close();
        writer.Flush();
        writer.Close();
        context.Response.ContentEncoding = System.Text.Encoding.UTF8;
        context.Response.ContentType = "text/xml";
        context.Response.Cache.SetCacheability(HttpCacheability.Public);
        context.Response.End();
    }
    private XmlTextWriter WriteRSSPrologue(XmlTextWriter writer)
    {
        writer.WriteStartDocument();
        writer.WriteStartElement("rss");
        writer.WriteAttributeString("version", "2.0");
        writer.WriteAttributeString("xmlns:dc", "http://purl.org/dc/elements/1.1/");
        writer.WriteAttributeString("xmlns:trackbac", "http://madskills.com/public/xml/rss/module/trackback/");
        writer.WriteAttributeString("xmlns:wfw", "http://wellformedweb.org/CommentAPI/");
        writer.WriteAttributeString("xmlns:slash", "http://purl.org/rss/1.0/modules/slash/");
        return writer;
    }
    private XmlTextWriter WriteRSSHeadChennel(XmlTextWriter writer)
    {
            writer.WriteStartElement("channel");
            writer.WriteElementString("title", "編程博客(Nickeyj's Blog) - 最新日志");
            writer.WriteElementString("link", HostUrl + "/ ");
            writer.WriteElementString("description", "編程博客(Nickeyj's Blog)");
            writer.WriteElementString("copyright", "2008 www.52bcnet.com");
            writer.WriteElementString("generator", "編程博客(Nickeyj's Blog)   RSS   生成器   2.0 ");
        return writer;
    }
    private XmlTextWriter AddRSSItem(XmlTextWriter writer, string pubDate, string sItemTitle, string sItemLink, string sItemDescription)
    {
        writer.WriteStartElement("item");
        writer.WriteElementString("title", sItemTitle);
        writer.WriteElementString("link", sItemLink);
        writer.WriteElementString("description", sItemDescription);
        writer.WriteElementString("pubDate", pubDate);
        writer.WriteEndElement();
        return writer;
    }
    private XmlTextWriter AddRSSItem(XmlTextWriter writer, string sItemTitle, string sItemLink, string sItemDescription, bool bDescAsCDATA)
    {
        writer.WriteStartElement("item");
        writer.WriteElementString("title", sItemTitle);
        writer.WriteElementString("link", sItemLink);
        if (bDescAsCDATA == true)
        {
            writer.WriteStartElement("description");
            writer.WriteCData(sItemDescription);
            writer.WriteEndElement();
        }
        else
        {
            writer.WriteElementString("description", sItemDescription);
        }
        writer.WriteElementString("pubDate", DateTime.Now.ToString("r"));
        writer.WriteEndElement();
        return writer;
    }
    private XmlTextWriter WriteRSSClosing(XmlTextWriter writer)
    {
        writer.WriteEndElement();
        writer.WriteEndElement();
        writer.WriteEndDocument();
        return writer;
    }
}

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

asp.net(c#) RSS功能實(shí)現(xiàn)代碼

asp.net(c#) RSS功能實(shí)現(xiàn)代碼:可能還有很多未完善,但終歸可以使用了,以后再慢慢改進(jìn)。 以下是我RSS界面的后臺(tái)代碼,給需要的朋友提供下我的經(jīng)驗(yàn): 代碼如下:using System; using System.Data; using System.Configuration; using System.Collections; us
推薦度:
標(biāo)簽: 實(shí)現(xiàn) 代碼 rs
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 欧美日韩一区二区三区在线观看 | 免费观看国产一区二区三区 | 欧美日韩国产精品综合 | 久久久久久久岛国免费播放 | 日韩午夜在线观看 | 日韩第一页在线观看 | 久久久精品久久久久久久久久久 | 欧美日韩精品一区二区三区四区 | 伊人毛片| julia一区 | 亲子交尾五十路 | 国产精品美女久久久久 | 91精品一区二区三区在线 | 久久精品1 | 日韩欧美系列 | 在线视频亚洲欧美 | 在线欧美色图 | 日韩欧美小视频 | 成人一a毛片免费视频 | 日韩经典第一页 | 日韩日韩日韩 | 美女毛片儿| 欧美日韩午夜 | 一区二区三区亚洲 | 国产精品第4页 | 日本国产最新一区二区三区 | 人禽性动交异族另类 | 国产成人综合欧美精品久久 | 亚洲 另类 在线 欧美 制服 | 一区二区三区在线视频观看 | 免费精品国产日韩热久久 | 全黄毛片 | 亚洲欧美激情精品一区二区 | 一区精品在线 | 亚洲欧美一 | 免费a级在线观看完整片 | 日韩二区三区 | 亚洲欧美一区二区三区不卡 | 日韩第二页 | 亚洲天码中文字幕第一页 | 国内精品视频免费观看 |