asp动态生成xmlasp

/ / 2018-06-02   阅读:2493
<!--#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 sq...
<!--#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>")

%>

上一篇:asp购物车源码

下一篇:asp随机密码

我要评论

昵称:
验证码:

最新评论

共0条 共0页 10条/页 首页 上一页 下一页 尾页
意见反馈