ASP + XML production menu management!
Menu. asp. This is the execution part on the foreground.
QUOTE:
<%
'---------------------------------------
'Author: Wild Grass
'Date: January 1, April 24, 2006
'Q Q: 94440079
'Group 51: 21643964 (group 51JS. COM)
'Site: http://www.yecaoweb.com OR http://www.yecaoweb.net
'---------------------------------------
'Reading XML file functions
Function YCMS_menu ()
Dim menu_temp, m
Set goxml = Server. CreateObject ("Microsoft. XMLDOM ")
Goxml. load (Server. MapPath ("menu. xml "))
Set goroot=goxml.doc umentElement. 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
'Determine if it is a pop-up window
If menu_open = 0 Then
'Judge whether it is the first one. If it is the first one, remove "marker"
If m = 0 Then
Menu_temp = menu_temp & "<a href = '" & menu_url & "'>" & menu_name & "</a>"
Else
Menu_temp = menu_temp & "external <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 & "external <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
'Output XML menu
Response. write (YCMS_menu ())
%>
Menu. xml XML data file
QUOTE:
<? Xml version = "1.0" encoding = "gb2312"?>
<Xml>
<Menu>
<Url name = "homepage" open = "0"> index. asp </url>
<Url name = "open" open = "0"> News. asp </url>
<Url name = "Document Center" open = "0"> Art. asp </url>
<Url name = "Image Display" open = "0"> Pic. asp </url>
<Url name = "audio and video entertainment" open = "0"> Dj. asp </url>
<Url name = "download resources" open = "0"> Down. asp </url>
<Url name = "comments" open = "0"> Book. asp </url>
<Url name = "open" open = "0"> Link. asp </url>
</Menu>
</Xml>
Admin_menu.asp: XML file management in the background
QUOTE:
<%
'Use the ADO. Stream component to save the file
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.exe cute ("menu. xml") %>
</Textarea>
<Input type = 'submit 'value = 'modify'/>
</Form>
</Body>
</Html>
Note: Due to time issues, you have no time to test it! I ^ _ ^ #
: Shifty: