程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> ASP XML制作菜單管理程序

ASP XML制作菜單管理程序

編輯:關於ASP編程
以下是menu.asp代碼
程序代碼
<%
'---------------------------------------
'作者:野 草
'日期:2006年4月24日
'Q Q:94440079
'---------------------------------------
'讀取XML文件函數
Function YCMS_menu()
dim menu_temp,m
Set goxml=Server.CreateObject("Microsoft.XMLDOM")
goxml.load(Server.MapPath("menu.xml"))
Set goroot=goxml.documentElement.selectSingleNode("menu")
m=0
For each child in goroot.childNodes
set childmenu=goroot.childnodes.item(m)
Dim menu_open,menu_title,menu_url
menu_open=childmenu.getAttributeNode("open").nodeValue
menu_name=childmenu.getAttributeNode("name").nodeValue
menu_url=goroot.childNodes.item(m).text
'判斷是否是彈出窗口
If menu_open=0 Then
'判斷是否是第一個,若是第一個則去掉"┊"
If m=0 Then
menu_temp=menu_temp&"<a href='"&menu_url&"'>"&menu_name&"</a>"
Else
menu_temp=menu_temp&"┊<a href='"&menu_url&"'>"&menu_name&"</a>"
End If
Else
If m=0 Then
menu_temp=menu_temp&"<a href='"&menu_url&"' target='o'>"&menu_name&"</a>"
Else
menu_temp=menu_temp&"┊<a href='"&menu_url&"' target='o'>"&menu_name&"</a>"
End If
End If
set childmenu=nothing
m=m+1
next
set goroot=nothing
set goxml=nothing
YCMS_menu=menu_temp
End Function
'輸出XML菜單
response.write(YCMS_menu())
%>
以下是menu.xml代碼:
程序代碼
<?xml version="1.0" encoding="gb2312"?>
<xml>
<menu>
<url name="網站首頁" open="0">index.asp</url>
<url name="新聞動態" open="0">News.asp</url>
<url name="文章中心" open="0">Art.asp</url>
<url name="圖片展示" open="0">Pic.asp</url>
<url name="影音娛樂" open="0">Dj.asp</url>
<url name="資源下載" open="0">Down.asp</url>
<url name="留言討論" open="0">Book.asp</url>
<url name="友情連接" open="0">Link.asp</url>
</menu>
</xml>
admin_menu.asp 後台管理XML文件部分
以下是admin_menu.asp
程序代碼
<%
'利用ADO.Stream組件保存文件
Function Save(file_body,file_name)
Set OS=Server.CreateObject("ADODB.Stream")
OS.Type=2
OS.Open
OS.Charset="GB2312"
OS.Position=OS.Size
OS.WriteText=file_body
OS.SaveToFile Server.MapPath(file_name),2
OS.Close
Set OS=Nothing
End Function
if Request.QueryString("action")="ok" then
call Save(Request.Form("content"),"menu.xml")
end if
%>
<html>
<head>
<title></title>
</head>
<body>
<form action="?action=ok" method="post">
<textarea style='width:500px;height:200px;' name='content'>
<%=server.execute("menu.xml")%>
</textarea>
<input type='submit' value='修 改' />
</form>
</body>
</html>
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved