Use ASP + Access to create a website RSS-formatted Content Abstract

Source: Internet
Author: User
Tags format definition

RSS is a lightweight, multi-purpose, scalable metadata description and joint promotion format. It can also be understood as a standard. It is an XML format used to provide selective and summarized web content for the content integration client. Today, many sites have begun to provide content integration services to viewers by creating RSS feeds, and provide news and site content updates. Visitors can easily obtain the organization and summary information through some client software.
So how can we create an RSS feed on our own website? The following uses ASP + access as an example.
Since RSS is a document in XML format, we should be able to filter and organize the data in the background database according to the conditions, and then generate a data stream in XML format through ASP, finally, it is sent to the client for browsing.
The selection and collection of data is a masterpiece of ASP. The key lies in how to generate data streams in XML format. In fact, Asp has its own solution, that is, to define the contenttype attribute of the response object before writing data. If the value of response. contenttype is "text/XML", an XML data stream is sent to the browser.
The method for calling the RSS source in the IE browser is no different from that for common links. The format is:
<A type = "application/RSS + XML" href = "rssfeed. asp"> RSS description </a>
Type = "application/RSS + XML" does not seem to have any difference when adding "no.

The following Program section is the "100,000 why" (http://www.why100000.com/) for creating my website /) Source Code
of the RSS feed in "Technical news", with the file name rssfeed_news.asp.
the variable sxmlclear is used to declare the generated document as an XML document. This declaration is optional to maintain backward compatibility with the old XML version.
.

Srsshead defines the basic elements of RSS. RSS feed consists of four main elements: <channel>, & L t; image>, <item>, and
<Textinput>. The <channel> element is required, and the <item> element must appear at least once. The <textinput> and <image> elements are optional,
Whether to use it depends on the actual situation.
<Channel> the element contains a brief description of the channel (the source of the RSS feed. <Title> is the channel name/title; <link> is
The URL of the webpage that contains the complete content; <description> is a simple description related to the content of <channel>; <language> represents the language.
There are some other attributes, which are not too common.
<Item> the element is used to describe the records in the database. <Item> generally, there are several items that correspond to the data set of an RSS feed.CopyCodeThe Code is as follows: <! -Filename: rssfeed_news.asp: -->
<% Option explicit %>
<! -- # Include file = "./Conn. Inc" -->

<%
Dim ssql, RS, scrlf, sxmlclear, srsshead, srssend
Scrlf = CHR (13) & CHR (10) 'Carriage return + line feed

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> whydomain0.com News Center </docs>" & scrlf
Srsshead = srsshead & "<generator> RSS generator by www. why00000.com </generator>" & scrlf

Srssend = "</channel> </RSS>"

Response. charset = "gb2312" 'Dataset
Response. contenttype = "text/XML" 'data stream format definition

'Output:
Response. Write sxmlclear
Response. Write srsshead

Ssql = "select top 15 * 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 while 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
Rs. movenext
Loop
End if
Rs. Close
Set rs = nothing

Response. Write srssend
%>

The Calling format in IE is: <a href = "http://www.why100000.com/_news/RssFeed_news.asp";> technical news

RSS </a>. If you use some client software to subscribe to this RSS feed, the subscription URL is http://www.why00000.com/_news/rssfeed_news.asp.

Related Article

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.