asp表示的rss生成xml文件的问题 兄弟们帮忙看看

jackymi 2005-08-18 09:48:52
下边用源代码用http://localhost/RssFeed_news.asp浏览rss没有问题(以xml形式表示)

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

<%
Dim sSQL, rs, sCrLf, sXmlClear, sRssHead, sRssEnd
sCrLf = chr(13) & chr(10) ’回车+换行

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" ’数据集
Response.ContentType="text/xml" ’数据流格式定义

’输出:
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 & sCrLf
rs.movenext
loop
end if
rs.close
set rs=nothing

Response.write sRssEnd
%>


下边是通过上边的代码生成的结果

<?xml version="1.0" encoding="gb2312" ?>
- <rss version="2.0">
- <channel>
<title>Why100000</title>
<description>Why100000</description>
<link>http://news.why100000.com/</link>
<language>zh-cn</language>
<docs>Why100000.COM News Center</docs>
<generator>Rss Generator By www.Why100000.COM</generator>
- <item>
<title>Owner</title>
<link>http://www.why100000.com</link>
<author>Wolski Zajazd</author>
<pubDate />
</item>
- <item>
<title>Owner/Marketing Assistant</title>
<link>http://www.why100000.com</link>
<author>Wilman Kala</author>
<pubDate />
</item>
- <item>
<title>Owner</title>
<link>http://www.why100000.com</link>
<author>White Clover Markets</author>
<pubDate>WA</pubDate>
</item>
- <item>
<title>Sales Manager</title>
<link>http://www.why100000.com</link>
<author>Wellington Importadora</author>
<pubDate>SP</pubDate>
</item>
- <item>
<title>Accounting Manager</title>
<link>http://www.why100000.com</link>
<author>Wartian Herkku</author>
<pubDate />
</item>
- <item>
<title>Sales Representative</title>
<link>http://www.why100000.com</link>
<author>Die Wandernde Kuh</author>
<pubDate />
</item>
- <item>
<title>Accounting Manager</title>
<link>http://www.why100000.com</link>
<author>Vins et alcools Chevalier</author>
<pubDate />
</item>
- <item>
<title>Sales Agent</title>
<link>http://www.why100000.com</link>
<author>Victuailles en stock</author>
<pubDate />
</item>
- <item>
<title>Sales Manager</title>
<link>http://www.why100000.com</link>
<author>Vaffeljernet</author>
<pubDate />
</item>
- <item>
<title>Sales Associate</title>
<link>http://www.why100000.com</link>
<author>Trail's Head Gourmet Provisioners</author>
<pubDate>WA</pubDate>
</item>
- <item>
<title>Sales Representative</title>
<link>http://www.why100000.com</link>
<author>Tradi??o Hipermercados</author>
<pubDate>SP</pubDate>
</item>
- <item>
<title>Owner</title>
<link>http://www.why100000.com</link>
<author>Tortuga Restaurante</author>
<pubDate />
</item>
- <item>
<title>Marketing Manager</title>
<link>http://www.why100000.com</link>
<author>Toms Spezialit?ten</author>
<pubDate />
</item>
- <item>
<title>Marketing Assistant</title>
<link>http://www.why100000.com</link>
<author>The Cracker Box</author>
<pubDate>MT</pubDate>
</item>
- <item>
<title>Marketing Manager</title>
<link>http://www.why100000.com</link>
<author>The Big Cheese</author>
<pubDate>OR</pubDate>
</item>
</channel>
</rss>


我现在想把上边的内容生成 RssFeed_news.xml 该怎么做???

...全文
262 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackymi 2005-08-19
  • 打赏
  • 举报
回复
呵呵 已经用fso搞定啦 谢谢楼上的兄弟 :)
  • 打赏
  • 举报
回复
方法两种,一种是msxml的save方法,另一种是fso,你任意用一种方法都好的,建议用fso,效率好一些
jackymi 2005-08-19
  • 打赏
  • 举报
回复
up

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧