微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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",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>")

%>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐