<%
Class clsMenuInfo
    Public menuName     ' 메뉴명
    Public menuLink     ' 메뉴 링크
    Public menuStep     ' 메뉴 단계
End Class

Dim XMLDOM, Rootnode, Currentnode, xml_filename, i,j,k, nCount
dim lowtree     ' 하위 노드 여부
dim c_lowtree   ' 하위 하위 노드 여부

nCount = 0

xml_filename = Request.ServerVariables("APPL_PHYSICAL_PATH")& "tree.xml"
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.load xml_filename

'--------------------------------------------------
' 1 depth
'--------------------------------------------------
Set Rootnode = XMLDOM.DocumentElement
For i = 0 to Rootnode.Childnodes.length - 1
    lowtree = Rootnode.Childnodes(i).Attributes(1).Text
    if lowtree = "true" then
        ReDim Preserve menuInfo(nCount + 1)
        Set menuInfo(nCount) = New clsMenuInfo
        menuInfo(nCount).menuName   = Rootnode.Childnodes(i).Attributes(0).Text
        menuInfo(nCount).menuLink   = ""
        menuInfo(nCount).menuStep   = "1"
        nCount = nCount + 1
        '--------------------------------------------------
        ' 2 depth
        '--------------------------------------------------
        Set Childnode = Rootnode.Childnodes(i)
        For j = 0 to Childnode.Childnodes.length - 1
            c_lowtree = Childnode.Childnodes(j).Attributes(1).Text
            if c_lowtree = "true" then
                ReDim Preserve menuInfo(nCount + 1)
                Set menuInfo(nCount) = New clsMenuInfo
                menuInfo(nCount).menuName   = Childnode.Childnodes(j).Attributes(0).Text
                menuInfo(nCount).menuLink   = ""
                menuInfo(nCount).menuStep   = "2"
                nCount = nCount + 1
                '--------------------------------------------------
                ' 3 depth
                '--------------------------------------------------            
                Set ChildChildnode = Childnode.Childnodes(j)
                For k = 0 to ChildChildnode.Childnodes.length - 1
                    ReDim Preserve menuInfo(nCount + 1)
                    Set menuInfo(nCount) = New clsMenuInfo
                    menuInfo(nCount).menuName   = ChildChildnode.Childnodes(k).Attributes(0).Text
                    menuInfo(nCount).menuLink   = ChildChildnode.Childnodes(k).Attributes(2).Text
                    menuInfo(nCount).menuStep   = "3"
                    nCount = nCount + 1
                next
            else
                ReDim Preserve menuInfo(nCount + 1)
                Set menuInfo(nCount) = New clsMenuInfo
                menuInfo(nCount).menuName   = Childnode.Childnodes(j).Attributes(0).Text
                menuInfo(nCount).menuLink   = Childnode.Childnodes(j).Attributes(2).Text
                menuInfo(nCount).menuStep   = "2"
                nCount = nCount + 1
            end if
        next
    else
        ReDim Preserve menuInfo(nCount + 1)
        Set menuInfo(nCount) = New clsMenuInfo
        menuInfo(nCount).menuName   = Rootnode.Childnodes(i).Attributes(0).Text
        menuInfo(nCount).menuLink   = Rootnode.Childnodes(i).Attributes(2).Text
        menuInfo(nCount).menuStep   = "1"
        nCount = nCount + 1
    end if
Next

for i = 0 to UBound(menuInfo) - 1
    strMenuName = menuInfo(i).menuName
    strMenuLink = menuInfo(i).menuLink
    strMenuStep = menuInfo(i).menuStep
   
    for j = 2 to strMenuStep
        strOut = strOut & "    "
    next
    strOut = strOut & "<input type=""checkbox"" name=""auth_menu"" value=""" &strMenuLink& """ id=""id_" & i & """>"
    strOut = strOut & "<label for=""id_" & i & """>" & strMenuName & "</label><br>" & vbCrLf
   
next

Response.Write strOut

Set Rootnode = nothing
Set Childnode = nothing
Set ChildChildnode = nothing
Set XMLDOM = nothing
%>

+ Recent posts