asp动态生成xmlasp
<!--#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>")
%>
<%
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>")
%>
我要评论