ASP + XML production menu management!

Source: Internet
Author: User

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:
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.