<% Dim conn,connstr,db db="db.mdb" Set Conn = Server.CreateObject("ADODB.Connection") connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"") Conn.Open connstr If Err Then err.Clear Set Conn = Nothing Response.Write "<br><br><div align=center>数据库连接出错,请检查连接字串。</div>" Response.End End If
set rs=server.createobject("adodb.recordset") rs.open"select * from flash",conn,1,3
'生成xml xmlfile=server.mappath("flash.xml") Set fso = CreateObject("Scripting.FileSystemObject") Set MyFile = fso.CreateTextFile(xmlfile,True) MyFile.WriteLine("<?xml version=""1.0"" encoding=""gb2312""?>") MyFile.WriteLine("<news>")
rs.movefirst '记录指针移至第一条记录上
while not rs.eof '当指针未到结尾时执行此循环
MyFile.WriteLine("<item title='"&rs("title")&"' data='"&rs("time")&"'>"&rs("content")&"</item>")
rs.movenext '指针移至下一条记录
wend rs.close Set rs = Nothing conn.close set conn=Nothing
MyFile.WriteLine("</news>") MyFile.Close %>
<script language="JavaScript"> alert('生成xml文件成功'); </script> <script language="javascript"> <!-- function clock(){i=i-1 if(i>0)setTimeout("clock();",1000); else self.close();} var i=0.5 clock(); //--> </script>
|