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.