SoFunction
Updated on 2025-04-08

Create a summary of RSS content in websites using ASP+Access

RSS is a "lightweight, multi-purpose, extensible metadata description and joint promotion format" that can also be understood as a specification. It itself is an XML format used to provide selective, aggregated Web content for content integration clients. Nowadays, many sites have begun to provide content integration services to viewers by creating RSS feeds, providing updates to news, site content, etc. Viewers can easily obtain these organized and summarized information through some client software.
So, how do you create an RSS feed on our own website? Let me introduce it below using Asp+Access as an example.
Since RSS is an XML-format document, we should be able to filter and organize the data in the background database according to conditions, and then generate an XML-format data stream through ASP, and finally send it to the client for browsing.
Data selection and collection are Asp's specialty, and the key lies in how to generate XML-format data streams. In fact, Asp already has its own solution, which is to define the ContentType property of the response object before writing data. If the value of   is "text/xml", a data stream in XML format will be sent to the viewer.
The method of calling RSS source in the IE browser is no different from ordinary links, the format is:
<a type="application/rss+xml" href="">RSS instructions</a>
Among them, type="application/rss+xml" seems to be no difference whether it is added or not.

The following program segment is the source code of the RSS feed that creates the "Technical News" column on my website "100,000 Whys" (http:///)
, the file name is RssFeed_news.asp.
Among them, the variable sXmlClear is used to declare that the generated document is a document in XML format, which is optional to maintain backward compatibility with older versions of XML.
sex.

sRssHead Defines the basic elements of Rss. RSS feed is usually composed of 4 main elements: <channel>, &l t;image>, <item> and
<textinput>. Among them, the <channel>  element is required, and the <item>  element must appear at least once. <textinput>  and <image>  elements are optional,
Whether to use it depends on the specific circumstances.
The <channel> element contains a simple description of Channel (the source of RSS feed). <title> is the name/title of the channel; <link> is the same as the channel content;
The URL of the web page that should contain the complete content; <description> is a simple description related to the content of <channel> ; <language>  represents language.
There are some other attributes that are not very commonly used.
The <item> element is used to describe records in the database. <item> Generally there are several items, corresponding to a data set of Rss feed.
Copy the codeThe code is as follows:

<!-Filename:RssFeed_news.asp:--> 
<% Option explicit %> 
<!-- #include file="./" --> 

<% 
  Dim sSQL, rs, sCrLf, sXmlClear, sRssHead, sRssEnd 
sCrLf = chr(13) & chr(10) 'Enter + line break

  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./<;/link>" & sCrLf 
  sRssHead = sRssHead & "<language>zh-cn</language>" & sCrLf 
  sRssHead = sRssHead & "<docs> News Center</docs>" & sCrLf 
  sRssHead = sRssHead & "<generator>Rss Generator By WWW.</generator>" & sCrLf 

  sRssEnd = "</channel></rss>" 

="gb2312" 'Dataset
="text/xml" 'Data stream format definition

'Output:
   sXmlClear 
   sRssHead 

  sSQL="select top 15 * from news order by sortid desc" 
  Set rs = ("") 
   sSQL, s_Conn, 1, 1 
  if not ( and ) then 
    do while not  
       "<item>" & sCrLf 
       "<title> " & rs("f_topic") & " </title>" & sCrLf 
       "<link> " & "http:///_news/show_a_new.asp?autof_i_autoid") & " </link>" & sCrLf 
       "<author> " & rs("f_author") & " </author>" & sCrLf 
       "<pubDate> " & rs("f_datetime") & " </pubDate>" & sCrLf 
       "</item>" & sCrLf & sCrLf 
       
    loop 
  end if 
   
  set rs=nothing 

   sRssEnd 
%> 

The call format in IE is: <a href="http:///_news/RssFeed_news.asp";>Technical News

RSS</a>. If you use some client software to subscribe to this RSS, the subscribed URL is http:///_news/RssFeed_news.asp.