<!--#include file="jtxw/strconnection.asp"-->
<%
Dim sSQL, rs, sCrLf, sXmlClear, sRssEnd,SQL,Xmlzj,Xmlzh
sCrLf = chr(13) & chr(10) '回车+换行
Xmlzj=""
sXmlClear = "<?xml version='1.0' encoding='gb2312'?>" & sCrLf '开始
sXmlClear =sXmlClear& "<RSS VERSION='2.0'>"& sCrLf
'中间没有用程序控制,直接用的ASP打印出来的
sRssEnd="</RSS>"'结束
'下面就是输入:中间的内容
Set rs=Server.CreateObject("ADODB.Recordset")
SQL="SELECT top 50 * FROM jtnews order by newid desc"
rs.open sql,conn,1,3
while not rs.Eof
Xmlzj= Xmlzj&"<channel>"&sCrLf
Xmlzj= Xmlzj&"<title>交通规划</title>"&sCrLf
Xmlzj= Xmlzj&"<link>http://www.cqjt.gov.cn/</link>"&sCrLf
Xmlzj= Xmlzj& "<item>"&sCrLf
Xmlzj= Xmlzj& "<title>"&rs("title")&"</title>"&sCrLf
Xmlzj= Xmlzj& "<link>http://www.cqjt.gov.cn/new.aspx?id="&rs("newid")&"</link>"&sCrLf
Xmlzj= Xmlzj&"<pubDate>"&rs("dateandtime")&"</pubDate>"&sCrLf
Xmlzj= Xmlzj&"<type>0</type>"&sCrLf
Xmlzj= Xmlzj&"<id>"&rs("newid")&"</id>"&sCrLf
Xmlzj= Xmlzj& "<description><![CDATA["&rs("content")&"]]></description>"&sCrLf
Xmlzj= Xmlzj& "</item>"&sCrLf
Xmlzj= Xmlzj& "</channel>"&sCrLf
rs.MoveNext
wend
set rs=nothing
conn.Close
set conn = nothing
Xmlzh=sXmlClear&Xmlzj&sRssEnd
Const ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(Server.MapPath("test.xml"), ForWriting, True)
f.WriteLine Xmlzh
f.Close
set fso = nothing
%>
此代码我测试过,XML部分能正常显示成XML,但是我要的是要它生成一个独立XML文件,而不是在原来的ASP页上显示成XML,为什么我写出数据的时候红颜色的地方报错,说是无效参数,哪位高手能给我讲讲吗`?
谢谢``````````````````````
[此贴子已经被作者于2006-10-26 17:00:04编辑过]