以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML工具及XML开发环境 』  (http://bbs.xml.org.cn/list.asp?boardid=7)
----  请问如何将.asp文件生成.xml文件?求教  (http://bbs.xml.org.cn/dispbbs.asp?boardid=7&rootid=&id=15857)


--  作者:appleparty
--  发布时间:3/21/2005 12:30:00 PM

--  请问如何将.asp文件生成.xml文件?求教
因为本人想给自己的网站建立rss新闻聚合功能,所以写了一段asp生成xml的程序,但是有些新闻聚合阅读器不支持 类型为.asp生成的xml文件,就是说不认.asp的文件,比如周伯通阅读器,所以我只好请大家帮忙,帮我想想如何生成,xml格式的文件.谢谢大家了.
asp源代码如下:  rss.asp

<%Response.contentType = "text/xml"%>
<?xml version="1.0" encoding="gb2312"?>
<!-- Source download URL: http://www.oioj.com/blog/rss2.asp       -->
<rss version="2.0">
<%
dim connstr,conn
dim rs,SQL
const issqldate=false
if not issqldate then
 Dim Db
 Db = "data/db.mdb"  '这是数据库路径
 set conn=server.createobject("adodb.Connection")
 connstr="provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DB)
end if
'Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
'set rs=conn.execute("select siteurl,sitetitle,copyrighturl,webmastername,webmasteremail from bloginfo")
'url=trim(rs(0))
%>
<channel>
<title>新闻</title>
<link>http://www.shenton.com.cn</link>
<description>shenton property</description>
<copyright>shentongroup</copyright>
<language>zh-cn</language>
<generator>www.shenton.com.cn</generator>
<webMaster>loujiyang</webMaster><%
'show_username=ReplaceBadChar(request.QueryString("name"))
'set rs = Server.CreateObject("ADODB.Recordset")
'以下是sql语句
SQL = "select top  20 * from News where online=true and date()<OffDate and date()>=PubDate order by NewsId desc"

set rs=conn.execute(SQL)
if rs.Eof or rs.Bof then
  response.write "<item></item>"
end if
while not rs.Eof
    response.Write "<item>" & vbcrlf
 Response.write "<title><![CDATA["&rs("NewsTitle")&"]]></title>" & vbcrlf
 response.write "<link>www.shenton.com.cn/news_detail.asp?NewsId="&rs("NewsId")&"</link>" & vbcrlf
' response.write "<author>"&rs("username")&"</author>" & vbcrlf
 response.write "<pubDate>"&rs("PubDate")&"</pubDate>" & vbcrlf
'  response.write "<description><![CDATA["&rs("logtext")&"]]></description>" & vbcrlf
 response.write "</item>"
 rs.MoveNext          
wend                  
set rs=nothing
conn.Close
set conn = nothing
function ReplaceBadChar(strChar)
 if strChar="" then
  ReplaceBadChar=""
 else
  ReplaceBadChar=replace(replace(replace(replace(replace(replace(replace(strChar,"'",""),"*",""),"?",""),"(",""),")",""),"<",""),".","")
 end if
end function
%></channel></rss>

asp程序已经可执行,下面需要生成一个 .xml文件,请各位帮忙!!


--  作者:appleparty
--  发布时间:3/21/2005 12:30:00 PM

--  
晕,怎么我刚刚发的帖子 变成 2000年1月1日发的了,这网站太搞笑了把
--  作者:appleparty
--  发布时间:3/21/2005 12:30:00 PM

--  
请大家帮我看看,怎么改,谢谢,刚才的日期网站的系统肯定错了,望及时更正
--  作者:coolfax
--  发布时间:6/16/2005 2:07:00 PM

--  
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
'把下面的地址替换成你的首页的文件地址,一定要用http://开头的绝对路径,不能写相对路径
xml.Open "GET", "http://www.phpup.com", False
xml.Send  
BodyText=xml.ResponseBody
BodyText=BytesToBstr(BodyText,"gb2312")
Set xml = Nothing
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile= fso.CreateTextFile(server.MapPath("aa.htm"), True)
MyFile.WriteLine(BodyText)
MyFile.Close
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
93.750ms