制作Flash网站模板中用ASP生成XML文件的方法

作者:     来源:      浏览次数:      发布时间:2013-08-08 14:17:23

Flash网站一般都需要调用XMl文件来实现方便的修改网站内容操作,而Flash网站模板则通常都会有后台来更新网站内容,也就是我们常说的ASP+FLASH+XML做的flash网站,一般是采用ASP生成XML文件方法来解决这一问题,下面就分享一些方法:

 

程序代码如下:
<!–#include file=”conn.asp”–>
<%’从数据库中读数据
dim i
dim TopicID(7),BoardID(7),Caption(7),LastTime(7)
‘——————-读数据
set rs = Server.CreateObject(“Adodb.recordset”)
sql = “Select * from new order by new_id desc”
rs.open sql,conn,1,1
i=1
do while not rs.eof
TopicID(i)=rs(“New_ID”)
BoardID(i)=rs(“new_topic”)
Caption(i)=rs(“new_stype”)
LastTime(i)=rs(“new_date”)
rs.movenext
i=i+1
if i > 7 then exit do
loop
‘——————生成xml
Set f = Server.CreateObject(“Scripting.FileSystemObject”)
‘Set myfile = f.Createtextfile(server.mappath(file),true)
files = “output.xml” ‘文件输出路径
Set myfile = f.Createtextfile(server.mappath(files),true)
myfile.writeline “<?xml version=”"1.0″” encoding=”"gb2312″”?>”
myfile.writeline “<data>”
for i=1 to 7
myfile.writeline “<gong>”
myfile.writeline “<TopicID>”&TopicID(i)&”</TopicID>”
myfile.writeline “<BoardID>”&BoardID(i)&”</BoardID>”
myfile.writeline “<Caption>”&Caption(i)&”</Caption>”
myfile.writeline “<LastTime>”&LastTime(i)&”</LastTime>”
myfile.writeline “</gong>”
next
myfile.writeline “</data>”
myfile.close
%>

 

项目中使用:
程序代码如下:
<!–#include file=”conn.asp”–>
<%’从数据库中读数据
dim i
dim New_ID(10),New_topic(10),New_stype(10),New_pic(10)
‘——————-读数据
set rs = Server.CreateObject(“Adodb.recordset”)
sql = “Select * from new order by new_id desc”
rs.open sql,conn,1,1
i=1
do while not rs.eof
New_ID(i)=rs(“New_ID”)
New_topic(i)=rs(“new_topic”)
New_stype(i)=rs(“new_stype”)
New_pic(i)=rs(“new_pic”)
rs.movenext
i=i+1
if i > 10 then exit do
loop
‘——————生成xml
Set f = Server.CreateObject(“Scripting.FileSystemObject”)
‘Set myfile = f.Createtextfile(server.mappath(file),true)
files = “swf/imgList.xml” ‘文件输出路径
Set myfile = f.Createtextfile(server.mappath(files),true)
myfile.writeline “<?xml version=”"1.0″” encoding=”"gb2312″”?>”
myfile.writeline “<imgList>”
myfile.writeline “<pic>”
for i=1 to 10
myfile.writeline “<list path=’uploadfile/”&New_pic(i)&”‘ smallpath=’uploadfile/”&New_pic(i)&”‘ smallinfo=’”&New_stype(i)&”‘ news.asp?bigCate=今创工程&smallCate=”&New_stype(i)&” /list>”
next
myfile.writeline “</pic>”
myfile.writeline “<rollTime fade_in=”"10″”>4</rollTime>”
myfile.writeline “<text font=”"黑体”" size=”"12″” bold=”"true”" color=”"0xfffffff”"></text>”
myfile.writeline “</imgList>”
myfile.close
%>

Copyright © 2009-2019 广州建航信息科技有限公司 版权所有 粤ICP备13086796号-7
展开