asp动态生成xml

<!--#include file="../inc/conn.asp" -->
<%
dim rs,sql,id,title,url,strTemp

id=Request.QueryString("id")
title=request.Form("title")
url=request.Form("url")

if id<>"" then
	sql="select * from [videos] where id="&id
else
	sql="select * from [videos] where id is null"
end if
set rs = Server.CreateObject("adodb.recordset")
rs.open sql,conn,1,3
if id="" then rs.addnew
rs("title")=title
rs("url")=url
rs.update
rs.close

strTemp="<?xml version=""1.0"" encoding=""utf-8""?>"
strTemp=strTemp&"<playlist version=""1"" xmlns=""http://xspf.org/ns/0/"">"
strTemp=strTemp&"<trackList>"
rs.open "select * from videos",conn,1,1
if not rs.eof then
	while not rs.eof
		strTemp=strTemp&"<track>"
		strTemp=strTemp&"<title>"&rs("title")&"</title>"
		strTemp=strTemp&"<location>"&rs("url")&"</location>"
		strTemp=strTemp&"</track>"
	  rs.movenext
	wend
end if
rs.close
set rs=nothing
strTemp=strTemp&"</trackList>"
strTemp=strTemp&"</playlist>"

Function saveXml(Text,FileName)    
	dim xmldoc,path 
	set xmldoc= server.CreateObject("MSXML.DOMDocument") 
	path = Server.MapPath(FileName) 
	xmldoc.LoadXML(Text) 
	xmldoc.save(path) 
	set xmldoc= nothing
End Function

call saveXml(strTemp,"../playlist.xml")
strUrl=request.ServerVariables("HTTP_REFERER") 
Response.Write("<script>alert('操作成功!');location.href='"&strUrl&"';</script>")

%>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值