<%
str=("<?xml version=""1.0"" encoding=""utf-8""?>")
str=str&("<bcaster autoPlayTime=""10"">")
sql_hdp="select id,j_url,j_img,j_title from jaes_hdp order by id asc"
Call RsOpen(Rs_hdp,sql_hdp,1,1)
for i=1 to 5
if Rs_hdp.eof then exit for
str=str&("<item
item_url=""upload/"&Rs_hdp("j_img")&"""
link="""&Rs_hdp("j_url")&""" itemtitle=""""></item>")
Rs_hdp.movenext:next
Call RsClose(Rs_hdp)
str=str&("</bcaster>")
'调用函数
call WriteTxtFile(str,"lib/bcastr.xml")
'生成XML文件函数
Function WriteTxtFile(Text,FileName)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile(Server.MapPath(FileName),true)
f1.Write (Text)
f1.Close
set fso = nothing
End Function
%>
上一篇:ASP创建文件夹函数
下一篇:ASP常用函数集
讨论数量:1
如有要考虑到编码问题,那就使用以下代码进行写入:
Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Open
.Charset = "utf-8"
.Position = objStream.Size
.WriteText = xmlStr
.SaveToFile server.mappath("/inc/website_set.xml"),2
.Close
End With
Set objStream = Nothing
具体“Scripting.FileSystemObject”与“ADODB.Stream”介绍请点击:http://www.hilo8.com/know/thread.php?id=702