sub_title
 ASP
제   목 asp로 xml 읽어 들이는 예제
작성자 웹스톤 등록일 2008-04-05 17:12:43 조회수 205,113
첨부화일 menu_xml_tree.zip   

<%
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 & ""
    strOut = strOut & "
" & vbCrLf
    
next

Response.Write strOut

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

출처: http://www.mungchung.com 

 
0
    
 
0
        list
 
※ 짧은 댓글일수록 예의를 갖추어 작성해 주시기 바랍니다.
line
reply cancel
 
번호 제목 글쓴이 추천 조회 날짜
56  [ASP] Html의 테그를 제거해주는 함수   member 다자래 0 / 0 206759 2008-08-20
55  ASP 런타임 에러값   member 오렌지 0 / 0 206137 2008-08-20
54  [ASP] 커서타입 & 락타입   member 오렌지 0 / 0 205550 2008-08-19
53  [ASP] IsEmpy() 함수와 IsNull() 함수의 차이   member 다자래 0 / 0 224134 2008-07-09
52  ASP 함수 모음   member 웹스톤 1 / 0 208801 2008-07-01
51  ASP로 RSS 만들기   member 웹스톤 0 / 0 208671 2008-06-26
50  [ASP] 랜덤링크 배열 이용   member 다자래 0 / 0 207430 2008-06-04
49  [ASP] 선택된 칼라테이블의 색상으로 텍스트의 색상을 바꾸기   member 다자래 0 / 0 204687 2008-06-04
48  ASP 사업자등록번호, 주민등록번호 체크 함수   member 웹스톤 0 / 0 205854 2008-05-07
47  [ASP] 저장된 html 파일을 이용한 메일 발송하기   member 다자래 0 / 0 210533 2008-04-13
46  asp로 xml 읽어 들이는 예제 첨부파일   member 웹스톤 0 / 0 205113 2008-04-05
45  [ASP] ASP에서 쿠키의 사용   member 다자래 0 / 0 207149 2008-03-06
44  [ASP] 캐쉬에 흔적을 남기지 않기   member 다자래 0 / 0 205859 2008-03-06
43  [ASP] 문자열이 몇 바이트인가 알아내는 함수   member 다자래 0 / 0 210387 2008-03-06
42  [ASP] 한글,영문,숫자가 섞인 문자열에서 항상 일정한 길이로 자르기  [1] member 다자래 0 / 1 208980 2008-03-01
41  [ASP] 선택된 칼라테이블의 색상으로 텍스트의 색상을 바꾸기   member 다자래 0 / 0 205114 2008-03-01
40  [ASP] DB를 이용한 랜덤배너 달기   member 다자래 0 / 0 205256 2008-03-01
39  [ASP] ASP에서 Eval 함수 쓰기   member 다자래 0 / 0 215215 2008-03-01
38  [ASP] 문자열 거꾸로 뒤집기   member 다자래 0 / 0 205554 2008-03-01
37  [ASP] 간단한 날짜 구하기(오늘은 몇주째인가?)   member 다자래 0 / 0 206811 2008-03-01
36  ASP에서 페이지의 환경변수(IP,URI,PORT....) 알아내기   member 억새풀 0 / 1 255480 2008-01-04
35  레코드셋 읽어서 변수 자동 생성   member 웹스톤 0 / 0 205693 2007-12-26
34  암호화/ 복호화 - 16진수 이용해서 한글도 가능 -_-   member 웹스톤 0 / 0 209306 2007-12-26
33  asp로 이미지 사이즈(크기) 얻는 함수   member 웹스톤 1 / 0 206297 2007-12-26
32  입력값이 들어왔을때 난수구하기!!   member 오렌지 0 / 0 204701 2007-12-03
write
button [1] [3] [4] button