Will you use RSS? Answer: No

Source: Internet
Author: User
When I checked the design of RBAC permission management, I saw the RSS content. I often used RSS. But I asked, Do you want to use RSS? Answer: No.
For more information, see the following article ( (Author:Li TianpingReprinted, please note) ):

In the Web2.0 era, Will RSS be used? (Technical Implementation summary)
From: http://www.cnblogs.com/ltp/archive/2006/01/15/317725.html

For example, we can see that web is in full swing, and there are also a lot of comments. Some people say that Web2.0 is "a group of people are watching the emperor's new clothes ". Some people also say that Web2.0 will be a revolution. No matter whether these arguments have value or not, I believe that existence has its inevitability. Maybe Web2.0 is more like a business model, a conceptual change than a non-technical one.
No matter what, it's here. Are you ready?
When it comes to Web, we will mention software applications such as BLOG, Tag, SNS, RSS, And wiki, as well as new theories and technical implementations such as XML and Ajax.
RSS is undoubtedly one of its important applications.

So what is RSS? What is its use?

RSS is a simple way to share content between sites (also known as "aggregate content"). It is usually used for news and other websites in order, such as blog websites. The website provides RSS output to help users discover updates to website content. Website users can read the content of the website that supports RSS output without opening the website content page by using the news aggregation tool software such as news and information reader on the client.
RSS is a form based on XML. All RSS files must comply with the XML 1.0 standard published by the W3C site. For details about the format, check the RSS 2.0 standard.

Below are the technical implementation of several RSS technologies I have summarizedCode:

1. generate an RSS feed online.

(1) Create RSS. aspx
<% @ Page Language = "C #" codebehind = "RSS. aspx. cs" autoeventwireup = "false" inherits = "litianping. RSS" %>
Only this row is left, and the rest are deleted.

(2) Background code; RSS. aspx. CS

Private void page_load (Object sender, system. eventargs E)
{
Response. contenttype = "text/XML ";
Response. Write (getrss ());
}

/// <Summary>
/// Obtain AggregationArticle
/// </Summary>
/// <Returns> </returns>
Public String getrss ()
{
News T = new news (); // Your Own Business Class
Dataset DS = T. getlistbyclass (1); // obtain data by category

Stringbuilder strcode = new stringbuilder ();
Strcode. append ("<? XML version = \ "1.0 \" encoding = \ "UTF-8 \" standalone = \ "Yes \"?> ");
Strcode. append ("<RSS version = '2. 0' xmlns: DC = \" http://purl.org/dc/elements/1.1 /\"");
Strcode. append ("xmlns: trackback = \" http://madskills.com/public/xml/rss/module/trackback /\"");
Strcode. append ("xmlns: WFW = \" http://wellformedweb.org/commentapi/\ "xmlns: Slash = \" http://purl.org/rss/1.0/modules/slash/\ "> ");
Strcode. append ("<channel> ");
Strcode. append ("<title> Li Tianping rssdemo </title> ");
Strcode. append ("<link> http: //" + request. servervariables ["SERVER_NAME"] + "</link> ");
Strcode. append ("<description> Tiandao rewards </description> ");
Strcode. append ("<copyright> copyright 2005 </Copyright> ");

Foreach (datarow row in DS. Tables [0]. Rows)
{
String id = row ["ID"]. tostring ();
String title = row ["title"]. tostring ();
String description = row ["Description"]. tostring ();
String pubdate = row ["pubdate"]. tostring ();
String classid = row ["classid"]. tostring ();
// String author = row ["author"]. tostring ();

strcode. append (" ");
strcode. append (" " + title + "");
strcode. append (" http: //" + request. servervariables ["SERVER_NAME"] + "/newsshow. aspx? Id = "+ ID +" ");
strcode. append (" " + description + " ");
strcode. append (" ");
strcode. append (" " + pubdate + " ");
strcode. append (" " + classid + " ");
strcode. append (" ");
}< br> strcode. append ("");
strcode. append ("");
return strcode. tostring ();
}

(3)Xmltextwriter implementation method 2; RSS. aspx. CS

String xmldoc = "RSS. xml ";
Private void page_load (Object sender, system. eventargs E)
{
Xmldoc = server. mappath (".") + xmldoc;
Getrss2 ();
Xmldocument Doc = new xmldocument ();
Doc. Load (xmldoc );
Response. contenttype = "text/XML ";
Doc. Save (response. output );
}
/// <Summary>
/// Obtain the aggregated article
/// </Summary>
/// <Returns> </returns>
Public void getrss2 ()
{
News T = new news ();
Dataset DS = T. getlistbyclass (1 );

Xmltextwriter writer = new xmltextwriter (xmldoc, encoding. utf8 );
Writer. Formatting = formatting. indented;
Writer. writestartdocument (true );
Writer. writecomment ("RSS page Implementation ");
Writer. writestartelement ("RSS ");
Writer. writeattributestring ("version", "2.0 ");
Writer. writestartelement ("channel ");
Writer. writestartelement ("title ");
Writer. writestring ("Li Tianping rssdemo ");
Writer. writeendelement ();
Writer. writestartelement ("Link ");
Writer. writestring ("http: //" + request. servervariables ["SERVER_NAME"]);
Writer. writeendelement ();
Writer. writestartelement ("Description ");
Writer. writestring ("Tiandao reward ");
Writer. writeendelement ();
Writer. writestartelement ("Copyright ");
Writer. writestring ("copyrights 2005 ");
Writer. writeendelement ();
Writer. writestartelement ("language ");
Writer. writestring ("ZH-CN ");
Writer. writeendelement ();

Foreach (datarow row in DS. Tables [0]. Rows)
{
String id = row ["ID"]. tostring ();
String title = row ["title"]. tostring ();
String description = row ["Description"]. tostring ();
String pubdate = row ["pubdate"]. tostring ();
String classid = row ["classid"]. tostring ();
// String author = row ["author"]. tostring ();

Writer. writestartelement ("item ");
Writer. writestartelement ("title ");
Writer. writestring (title );
Writer. writeendelement ();
Writer. writestartelement ("Link ");
Writer. writestring ("http: //" + request. servervariables ["SERVER_NAME"] + "/newsshow. aspx? Id = "+ id );
Writer. writeendelement ();
Writer. writestartelement ("Description ");
Writer. writecdata (description );
Writer. writeendelement ();
Writer. writestartelement ("pubdate ");
Writer. writestring (pubdate );
Writer. writeendelement ();
Writer. writestartelement ("category ");
Writer. writestring (classid );
Writer. writeendelement ();
Writer. writeendelement ();
}
Writer. writeendelement ();
Writer. writeendelement ();
Writer. Flush ();
Writer. Close ();

}
2. Get online RSS reading.

Page code:
<P style = "font-size: 11px">
Feed seed: <asp: textbox id = "feedurl" runat = "server" width = "PX"> </ASP: textbox> <br>
Number of entries displayed: <asp: textbox id = "num" runat = "server" width = "48px"> </ASP: textbox> </P>
<P style = "font-size: 11px">
<Asp: button id = "getfeed" runat = "server" text = "get RSS"> </ASP: button> <br>
<Br>
<Asp: Label id = "rssfeed" runat = "server"> </ASP: Label> </P>

Background code:
/// <Summary>
/// Obtain the feed seed data to be displayed
/// </Summary>
/// <Param name = "rssurl"> </param>
/// <Param name = "shownewscount"> </param>
/// <Returns> </returns>
Public String loadrss (string rssurl, int shownewscount)
{
String strrsslist = "";
String strmsg;
Try
{
Xmldocument objxmldoc = new xmldocument ();
Objxmldoc. Load (rssurl );
Xmlnodelist objitems = objxmldoc. getelementsbytagname ("item ");

If (shownewscount> 30)
Shownewscount = 10;
If (shownewscount <1)
Shownewscount = objitems. count;

String title = "";
String link = "";
Int I;

If (objxmldoc. haschildnodes = true)
{
I = 1;
Foreach (xmlnode objnode in objitems)
{
If (I <= shownewscount)
{
If (objnode. haschildnodes = true)
{
Xmlnodelist objitemschild = objnode. childnodes;
Foreach (xmlnode objnodechild in objitemschild)
{
Switch (objnodechild. Name)
{
Case "title ":
Title = objnodechild. innertext;
Break;
Case "Link ":
Link = objnodechild. innertext;
Break;
}
}
I = I + 1;
Strrsslist + = "<a href =" + link + "target = _ blank>" + title + "</a> <br> ";
}
}
}
}
Strmsg = strrsslist;
}
Catch
{
Strmsg = "error in RSS feed source data! ";
}
Return strmsg;
}

// Obtain the specified RSS
Private void getfeed_click (Object sender, system. eventargs E)
{
If (feedurl. Text = "") // RSS address
{
Rssfeed. Text = "the information source cannot be blank. You can refresh and try again or contact the administrator! ";
Return;
}
Rssfeed. Text = loadrss (feedurl. Text, convert. toint32 (Num. Text); // get the specified number
}

3. online RSS reading for refreshing dynamic updates

<% @ Page Language = "C #" codebehind = "XMLHTTP. aspx. cs" autoeventwireup = "false" inherits = "litianping. XMLHTTP" %>
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> XMLHTTP </title>
<Meta name = "generator" content = "Microsoft Visual Studio. NET 7.1">
<Meta name = "code_language" content = "C #">
<Meta name = "vs_defaultclientscript" content = "JavaScript">
<Meta name = "vs_targetschema" content = "http://schemas.microsoft.com/intellisense/ie5">
<Style> TD {font-size: 9pt}
</Style>
<SCRIPT>
<! --
VaR odiv
VaR XH
Function getxml ()
{
XH = new activexobject ("Microsoft. XMLHTTP ");
Odiv = Document. getelementbyid ("rssitem ");
Odiv. style. Display = "";
Try
{
// If it is locally changed to the following statement, it is directly read
// XH. Open ("get", "/RSS. aspx", false );
XH. Open ("get", "http: // ltp.cnblogs.com/rss.aspx", false );
XH. Send (null );
Loaddata (XH, odiv );
}
Catch (E)
{
Error (odiv );
}
}
Function loaddata (XH, odiv)
{
If (XH. readystate = 4)
{
Xml = XH. responsexml;
VaR I;
VaR nodes = xml. selectnodes ("/RSS/channel/item ");
VaR bloglink = xml. selectsinglenode ("/RSS/channel/Link"). text;
Odiv. innerhtml = "";
VaR HTML;
For (I = 0; I <nodes. length; I ++)
{

HTML + = "<div> ";
HTML + = "<div> ";
HTML + = "<a class = font1 href = '" + nodes [I]. selectsinglenode ("Link "). text + "'target = '_ blank'>" + nodes [I]. selectsinglenode ("title "). text + "</a> <br> ";
HTML + = "</div> ";
HTML + = "<div> ";
HTML + = "" + nodes [I]. selectsinglenode ("Description"). text;
HTML + = "</div>"
// Html + = "</div> ";
HTML + = "</div> <HR> ";

}
Odiv. innerhtml = HTML;
}
Else
{
Error (odiv );
}
}

function error (odiv)
{< br> odiv. innerhtml = "loading failed ";
}< br> -->










loading data...





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.