數(shù)據(jù)庫 是access 有song 的表一個 "song"里的字段有 id name(歌名) img(圖片地址) url (歌曲地址) singer(歌手) lrc(歌詞) 想要按以下格式生成xml文件的 asp代碼如何寫??? 本人菜鳥一個 希望多多指教啊
<?xml version="1.0" encoding="utf-8"?>
<msg>
<list pic_url="圖片地址" title="歌名" singer="歌手" lrc_url="歌詞" >
<u u="歌曲地址" />
</list>
</msg>
數(shù)據(jù)庫連接文件在網(wǎng)站根目錄下有conn.asp
conn.asp 代碼是
<%
dim conn
dim dbpath
set conn=server.createobject("adodb.connection")
DBPath = Server.MapPath("data/#data_aboutplayer.mdb")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
%>
_____________________________________________________________________________________________________________
Dim xmlDoc,msgRs,sql,Node,Node1
sql = "select * from song order by Id"
Set msgRs = Server.CreateObject("ADODB.Recordset")
msgRs.open sql,conn,1,1
If not msgRs.eof then
Set xmlDoc = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
xmlDoc.AppendChild(xmlDoc.CreateNode(1,"msg",""))
while not msgRs.eof
Set Node = xmlDoc.CreateNode(1,"list","")
xmlDoc.DocumentElement.AppendChild(Node)
Node.SetAttribute "pic_url",msgRs("img")
Node.SetAttribute "title",msgRs("name")
Node.SetAttribute "singer",msgRs("singer")
Node.SetAttribute "lrc_url",msgRs("lrc")
Set Node1 = xmlDoc.CreateNode(1,"u","")
Node.AppendChild(Node1)
Node1.SetAttribute "u",msgRs("url")
msgRs.movenext
wend
xmlDoc.save(server.MapPath("song.xml"))
Set xmlDoc = nothing
Set Node = nothing
Set Node1 = nothing
End If
Set msgRs = Nothing
本站僅提供存儲服務,所有內容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權內容,請
點擊舉報。