快速业务通道

ASP.NETè?o?êμ????μ?μ?RSSê?3?

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-07-03

1?óúRss

RSSê?12?í?úèYμ?ò????òò×·?ê?,ò23???o?.í¨3£±?ó?óúD???oíBlog?£í???ìá1?RSSê?3?£?óDà?óúè?ó??§·¢??í????úèYμ??üD??£í???ó??§?éò??è?úóú?§3?RSSμ?D?????o?1¤??èí?t?ò???ú??í???£¨è?BLOGLINES£?£?????í???μ??úèY2¢?ú2?′ò?aí???ò3??μ??é???????á?úèY?£

RSSê??ùóúXMLμ?ò???D?ê?£???ì?1?·??ò?í2??μá?£?????ê?è?o?ê1ó?ASP.NETêμ??

í¨?a?ˉàà?÷í???ìá1?á?RSSê?3?£o

°?????μ??a??·??ú2??í?ò?a??μ?μ?<head>±ê???D

<link id="RSSLink" title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/lbk/rss.aspx" />

′′?¨RSS.ASPX???t

??á??????aò?DD£???óàμ???é?μ??£

<%@ Page language="c#" Codebehind="Rss.aspx.cs" AutoEventWireup="false" Inherits="Test.Rss" %>

oóì¨′ú??£?Rss.aspx.cs

?aà?XML???t?úèYμ?ê?3?ê?2éó??±?óê?3?×?·?′?μ?D?ê?£??ú?ò?′à′?°??±è???òμ¥£???ò2?éò?ê1ó?XmlTextWriterà′êμ???£

private void Page_Load(object sender, System.EventArgs e)
?? {
???? Response.ContentType="text/xml";
???? Response.Charset = "UTF-8";
???? Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
???? Response.Write("<rss version=\"2.0\"><channel>");
???? Response.Write(GetUserRSS());
???? GetItemsRss();
???? Response.Write("</channel></rss>");
}

//′?RSSμ?ò?D?D??¢
private string GetUserRSS(NewTaokee.Model.Users user)
???? {
???????? StringBuilder strRss = new StringBuilder();
???????? strRss.Append("<title>lbk</title>");
???????? strRss.Append("<link>lbk.cnblogs.com</link> ");
???????? strRss.Append("<description>o?o?£??íê??ò</description> ");
???????? strRss.Append("<language>zh-cn</language>");
???????? strRss.Append("<generator>www.xiaoqian.cn </generator>");
???????? return strRss.ToString();
???? }
//?-?·?áè?RSS?Dμ?????ITEMμ??úèY

private string getRss(IList<Model.Info> listInfo)
???? {
???????? StringBuilder strRss = new StringBuilder();
???????? foreach (Model.Info var in listInfo)
???????? {
???????????? string nickname = DAL.Users.instance.GetModelBasic(var.Author).NickName;
???????????? string content = Function.ReplaceHtml(var.Content);
???????????? content = Function.ReplaceXml(content);
???????????? content = (content.Length > 300) ? content.Substring(0, 300) + "" : content;
???????????? string link = Function.getConfig("MyUrl") + nickname + "/blog/item/" + var.id;
???????????? strRss.Append("<item>");
???????????? strRss.Append("<title>" + Function.ReplaceXml(var.Title) + "</title>");
???????????? strRss.Append("<author>" + nickname + "</author>&

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号