ASP生成XML文件

来源:风之相随blog 时间:2009-06-29 16:28:00 

今天一个项目上需要,修改了一些属性,测试成功。

<!--#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
%>

标签:xml,asp,文件
0
投稿

猜你喜欢

  • 关于axios如何全局注册浅析

    2024-04-27 16:03:40
  • Vue 服务端渲染SSR示例详解

    2024-05-28 15:50:39
  • 关于django 数据库迁移(migrate)应该知道的一些事

    2024-01-24 08:42:50
  • 深入浅出讲解MySQL的并行复制

    2024-01-21 20:22:26
  • python读取与处理netcdf数据方式

    2021-11-09 02:45:01
  • python使用timeit时间模块

    2023-03-05 16:27:37
  • python面向对象 反射原理解析

    2021-05-14 08:56:32
  • Python 聊聊socket中的listen()参数(数字)到底代表什么

    2022-10-17 00:49:25
  • Dreamweaver技巧50问

    2008-10-16 14:00:00
  • Hibernate Oracle sequence的使用技巧

    2009-06-19 17:25:00
  • Python中的各种装饰器详解

    2023-02-23 06:16:41
  • echarts动态获取Django数据的实现示例

    2022-08-26 02:29:06
  • 利用PHP函数计算中英文字符串长度的方法

    2023-10-13 16:35:46
  • Pandas常用累计、同比、环比等统计方法实践过程

    2021-03-13 01:48:36
  • 解决sublime+python3无法输出中文的问题

    2023-09-20 16:26:20
  • 浅谈python3中input输入的使用

    2022-05-15 22:32:57
  • Python简单实现图片转字符画的实例项目

    2023-02-24 02:01:47
  • 浅谈python处理json和redis hash的坑

    2023-08-01 10:51:14
  • 三种禁用FileSystemObject组件的方法

    2007-09-23 15:52:00
  • Python 获取新浪微博的最新公共微博实例分享

    2021-03-01 13:23:18
  • asp之家 网络编程 m.aspxhome.com