RSS is a "lightweight, multi-purpose, extensible metadata description and joint promotion format", can also be understood as a specification. It is an XML format that is used to provide selective and aggregated content-consolidation clients; Web content. Today, many sites start by creating RSS feeds to provide content integration services to viewers, providing news, site content updates, and so on. Visitors can easily get these organizations and aggregated information through some client software.
So, how do you create an RSS feed on our own web site? Below I take asp+access as an example to introduce.
since RSS is a document in XML format, we should be able to filter the data in the background database according to the conditions, and then generate the data stream in XML format through ASP, and finally send it to the client for browsing.
The selection and collection of
data is the forte of ASP, and the key is how to generate the data stream in XML format. In fact, the ASP has its own solution, is to write the data on the response object of the ContentType attribute to define. If response. The value of ContentType is "Text/xml", and the data stream in XML format is sent to the viewer.
in IE browser to invoke the RSS feed method and the common link is no different, the format is:
<a type= "Application/rss+xml" href= "rssfeed.asp" >rss description </a>
of which the type= "Application/rss+xml" plus does not add as if there is no difference.
The following program segment is the source code for the RSS feed for the "Technical News" section of the "100,000 Why" (http://www.why100000.com/) of my website
, the file name is rssfeed_news.asp.
where the variable sxmlclear is used to declare the resulting document as an XML-formatted document, the declaration is optional to maintain backward compatibility with older versions of XML
sex.
Srsshead defines the basic elements of RSS. RSS feeds usually consist of 4 main elements: <channel>,&l t;image>,<item> and
<textinput>. Where the,<channel> element is a required,<item> element must appear at least once. <textinput> and <image> elements are optional,
Whether the
is used depends on the specific circumstances.
The
<channel> element contains a simple description of the channel (the source of the RSS feed). <title> is the channel's name/title;<link> is with the channel content on
The url;<description> of the page that
should contain the complete content is a simple description;<language> representative language related to the content of <channel>.
There are other attributes that are not too often used.
The <item> element is used to describe the records in the database. <item> typically has several items that correspond to a collection of data for an RSS feed.
Copy Code code as follows:
<!-Filename:RssFeed_news.asp:-->
<% Option Explicit%>
<!--#include file= "./conn.inc"-->
<%
Dim sSQL, RS, Scrlf, Sxmlclear, Srsshead, Srssend
SCRLF = CHR & Chr (10) ' carriage return + linefeed
sxmlclear = "<?xml version= ' 1.0 ' encoding= ' gb2312 '?> '" & Scrlf
srsshead = "<rss version= ' 2.0 ' >" & Scrlf
Srsshead = srsshead & "<channel>" & Scrlf
srsshead = srsshead & "<title> Why100000 </title>" & Scrlf
srsshead = srsshead & "<description> Why100000 </description>" & Scrlf
srsshead = srsshead & "<link>http://news.why100000.com/<;/link>" & Scrlf
srsshead = srsshead & "<language>zh-cn</language>" & Scrlf
srsshead = srsshead & "<docs>why100000.com News center</docs>" & Scrlf
Srsshead = srsshead & "<generator>rss generator by www.why100000.com</generator>" & SCrLf
srssend = "</channel></rss>"
response.charset= "gb2312" DataSet
response.contenttype= "text/xml" Data flow format definition
' Output:
Response.Write Sxmlclear
Response.Write Srsshead
ssql= "SELECT top * from news ORDER BY sortid Desc"
Set rs = Server.CreateObject ("ADODB.") Recordset ")
Rs. Open sSQL, S_conn, 1, 1
If not (rs.eof and RS.BOF) then
do, not rs.eof
Response.Write "<item>" & Scrlf
Response.Write "<title>" & RS ("F_topic") & "</title>" & Scrlf
Response.Write "<link>" & "http://www.why100000.com/_news/show_a_new.asp?autoid="; &
rs ("F_i_autoid") & "</link>" & Scrlf
Response.Write "<author>" & RS ("F_author") & "</author>" & Scrlf
Response.Write "<pubDate>" & RS ("F_datetime") & "</pubDate>" & Scrlf
Response.Write "</item>" & Scrlf & Scrlf
Rs.movenext
Loop
End If
Rs.close
Set rs=nothing
Response.Write Srssend
%>
IE in the call format is: <a href= "http://www.why100000.com/_news/RssFeed_news.asp";> Technical News
rss</a>. If you subscribe to this RSS with some client software, the URL for the subscription is http://www.why100000.com/_news/RssFeed_news.asp.