当前位置:编程学习 > asp >>

asp生成xml文档实例程序代码

xml部分:

<?xml version="1.0" encoding="gb2312"?>
<bcastr>
<item item_url='../uploadpic/2010052660955221.jpg' link='http://www.bj365cn.com' <itemtitle='01'></item>
<item item_url='../uploadpic/2010052660981189.jpg' link='http://www.bj365cn.com' <itemtitle='02'></item>
<item item_url='../uploadpic/2010052661007093.jpg' link='http://www.bj365cn.com' <itemtitle='03'></item>
<item item_url='../uploadpic/2010052661261797.jpg' link='http://www.bj365cn.com' <itemtitle='04'></item>
<item item_url='../uploadpic/2010052661302501.jpg' link='http://www.bj365cn.com' <itemtitle='05'></item>
</bcastr>


------------------------------------------------------------------
asp教程部分:
-------------------------------------------------------------------
<%@language="vbscript" codepage="936"%>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>

<%
'建立数据库教程连接
set conn=server.createobject("adodb.connection")
dbpath = server.mappath("../##25gx##/#25gx#.mdb")
conn.open "provider=microsoft.jet.oledb.4.0; data source="&dbpath
'打开数据库表
exec="select * from wl_ad"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,3

'生成xml
xmlfile=server.mappath("../xml/bcastr.xml")
set fso = createobject("scripting.filesystemobject")
set myfile = fso.createtextfile(xmlfile,true)
myfile.writeline("<?xml version=""1.0"" encoding=""gb2312""?>")
myfile.writeline("<bcastr>")

rs.movefirst   '记录指针移至第一条记录上

while not rs.eof    '当指针未到结尾时执行此循环


'myfile.writeline("<item link='"&rs("wl_pic")&"' link='"&rs("wl_url")&"' <itemtitle='"&rs("wl_title")&"'></item>") 
myfile.writeline("<item item_url='"&rs("wl_pic")&"' link='"&rs("wl_url")&"' <itemtitle='"&rs("wl_title")&"'></item>") 

' 输出到文件

rs.movenext   '指针移至下一条记录

wend
rs.close
set rs = nothing
conn.close
set conn=nothing

myfile.writeline("</bcastr>")
myfile.close
%>


<script language="网页特效">
alert(':::更新成功:::');
</script>
<script language="网页特效">
<!--
function clock(){i=i-1
if(i>0)settimeout("clock();",1000);
else self.close();}
var i=0.5
clock();
//-->
</script>


</body>
</html>

补充:asp教程,XML相关 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,