ASP XML制作菜單管理程序
更新時(shí)間:2008年12月29日 20:52:13 作者:
利用asp+xml實(shí)現(xiàn)代碼管理,實(shí)際就是利用asp操作xml
以下是menu.asp代碼
程序代碼
<%
'---------------------------------------
'作者:野 草
'日期:2006年4月24日
'Q Q:94440079
'---------------------------------------
'讀取XML文件函數(shù)
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
'判斷是否是第一個(gè),若是第一個(gè)則去掉"┊"
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="網(wǎng)站首頁(yè)" open="0">index.asp</url>
<url name="新聞動(dòng)態(tài)" open="0">News.asp</url>
<url name="文章中心" open="0">Art.asp</url>
<url name="圖片展示" open="0">Pic.asp</url>
<url name="影音娛樂(lè)" 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 后臺(tái)管理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>
程序代碼
<%
'---------------------------------------
'作者:野 草
'日期:2006年4月24日
'Q Q:94440079
'---------------------------------------
'讀取XML文件函數(shù)
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
'判斷是否是第一個(gè),若是第一個(gè)則去掉"┊"
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="網(wǎng)站首頁(yè)" open="0">index.asp</url>
<url name="新聞動(dòng)態(tài)" open="0">News.asp</url>
<url name="文章中心" open="0">Art.asp</url>
<url name="圖片展示" open="0">Pic.asp</url>
<url name="影音娛樂(lè)" 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 后臺(tái)管理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>
相關(guān)文章
ASP頁(yè)面靜態(tài)化批量生成代碼分享(多種方法)
最近朋友網(wǎng)站需要將網(wǎng)站生成靜態(tài),但有時(shí)候生成靜態(tài)會(huì)出現(xiàn)問(wèn)題,特多整理了一些方法, 大家可以根據(jù)自己網(wǎng)站需要選擇。2011-05-05
aspupload文件重命名及上傳進(jìn)度條的解決方法附代碼
aspupload文件重命名及上傳進(jìn)度條的解決方法附代碼...2007-08-08
可以應(yīng)用到馬克斯電影站生成Rss Feed的代碼
前段時(shí)間為了給本人的電影站增加Rss訂閱功能,動(dòng)手寫(xiě)了個(gè)動(dòng)態(tài)生成Rss Feed的ASP代碼,沒(méi)法上傳附件,就直接貼代碼吧,反正也不長(zhǎng),用馬克斯做電影站的朋友直接拿去用吧,其它類型的站點(diǎn)修改一下也能用。生成的Rss Feed采用UTF-8編碼,經(jīng)過(guò)feedvalidator.org校驗(yàn),兼容Rss 2.0和Atom。2008-03-03
在Vista IIS 7 中用 vs2005 調(diào)試 Web 項(xiàng)目的注意事項(xiàng)
在Vista IIS 7 中用 vs2005 調(diào)試 Web 項(xiàng)目核心是要解決以下幾個(gè)問(wèn)題2008-09-09
asp漢字中文圖片驗(yàn)證碼的實(shí)現(xiàn)代碼
asp漢字中文圖片驗(yàn)證碼的實(shí)現(xiàn)代碼...2007-11-11
ASP刪除img標(biāo)簽的style屬性只保留src的正則函數(shù)
做手機(jī)網(wǎng)站的時(shí)候圖片要做自適應(yīng),由于手機(jī)網(wǎng)站跟PC網(wǎng)站共用1個(gè)數(shù)據(jù)庫(kù),導(dǎo)致文章內(nèi)的圖片有部分帶有:style=""等屬性,導(dǎo)致手機(jī)端圖片width:100%失效,去掉mg標(biāo)簽style屬性只保留src即可解決問(wèn)題2020-09-09

