Add RSS to your ASP + AC site

Source: Internet
Author: User

CopyCode The Code is as follows: <%
Response. contenttype = "text/XML"
Dim dB, dbpath, Conn
Dim RS, SQL
DB = "shujuku/hotltcom. mdb" ''' enter your database address here
Set conn = server. Createobject ("ADODB. Connection ")
Dbpath = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath (db)
Conn. Open dbpath
%>
<? XML version = "1.0" encoding = "gb2312"?> <RSS version = "2.0"> 'here is the XML version and language declaration.
<Channel>
'The following is equivalent to the meta part of HTML, including the title, connection, language, copyright information, and logo icon.
<Title> simple happiness </title>
<Link> http://siyizhu.com </link>
<Description> simple and happy </description>
<Language> ZH-CN </language>
<Copyright> copyright 2006 hotlt </Copyright>
<Webmaster> hotlt@tom.com </Webmaster>
<Image>
<Title> simple happiness </title>
<URL> http://siyizhu.com/logo.gif </URL>
<Link> http://siyizhu.com/</link> <description> siyizhu's weblog </description> </image>
'The following is the data table section connecting to the database. Top 15 indicates the latest 15 data tables, and movie indicates the data table.
<%
SQL = "select top 15 * from movie order by ID DESC"
Set rsw.conn.exe cute (SQL)
If Rs. EOF or Rs. bof then
Response. Write "<item> </item>"
End if
While not Rs. EOF
Title = RS ("title") 'Here the title is defined as the title, ("title") is the field name
Id = RS ("ID") '. The ID is the connection ID, and ("ID") is the field name.
Time = RS ("time") 'defines time as the field name ("time ").
Content = Replace (replace (left (RS ("content"), 200), "<", "<"), ">", "> ") 'Here content is the content field name.
'Below is the RSS output
Response. Write "<item>"
Response. Write "<title>" & Title & "</title>" 'output title
Response. Write "<link> http://siyizhu.com/weblog/article.asp? Id = "& ID &" </link> "'Here is the output link.
Response. Write "<author> siyizhu </author>" 'Here is the output author. If there is a field, you can call the field
Response. Write "<pubdate>" & time & "</pubdate>" 'Here is the time
Response. Write "<description> <! [CDATA ["& content &"]> </description> "'Here is the output description, because the code may be included. Otherwise, an error is prompted during preview.
Response. Write "</item>"
Rs. movenext
Wend
Set rs = nothing
Conn. Close
Set conn = nothing
%>
</Channel> </RSS>

Note: Pay attention to the use of [CDATA *]>, and try to use "[CDATA [*]>" for output such as content ",
* It is the output content. The content may be in the code format, such as spaces or ASP code. Otherwise, an error may occur.

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.