设为首页收藏本站
网站公告 | 这是第一条公告
     

 找回密码
 立即注册
缓存时间01 现在时间01 缓存数据 当你走完一段之后回头看,你会发现,那些真正能被记得的事真的是没有多少,真正无法忘记的人屈指可数,真正有趣的日子不过是那么一些,而真正需要害怕的也是寥寥无几。

当你走完一段之后回头看,你会发现,那些真正能被记得的事真的是没有多少,真正无法忘记的人屈指可数,真正有趣的日子不过是那么一些,而真正需要害怕的也是寥寥无几。

查看: 1389|回复: 2

Dom遍历XML的一个例子,结果为树状结构

[复制链接]

  离线 

TA的专栏

  • 打卡等级:常驻代表
  • 打卡总天数:35
  • 打卡月天数:1
  • 打卡总奖励:445
  • 最近打卡:2025-12-09 09:00:23
等级头衔

等級:晓枫资讯-上等兵

在线时间
0 小时

积分成就
威望
0
贡献
419
主题
377
精华
0
金钱
1667
积分
866
注册时间
2023-2-10
最后登录
2025-12-9

发表于 2023-2-14 15:28:51 | 显示全部楼层 |阅读模式
knowledge.XML文件
 
 
 
<知识管理 name="知识管理" type="rt" id="rt000"> 
  <目录 name="vc++" type="ml" id="ml003"/> 
  <目录 name="asp" type="ml" id="ml001"> 
     <知识 name="什么是ASP 1" type="zs" id="zs001"> 
        什么是ASP 
        cxx 
        2001-02-20 
        ASP:Active Server Page 
      
     <知识 name="什么是ASP 2" type="zs" id="zs002"> 
        什么是ASP 
        cxx 
        2001-02-20 
        ASP:Active Server Page 
      
   
  <目录 name="vbs" type="ml" id="ml002"> 
     <知识 name="什么是vbs 1" type="zs" id="zs003"> 
        什么是ASP 
        cxx 
        2001-02-20 
        ASP:Active Server Page 
      
     <知识 name="什么是vbs 2" type="zs" id="zs004"> 
        什么是ASP 
        cxx 
        2001-02-20 
        ASP:Active Server Page 
      
   
 
<留言簿 name="留言簿" type="ly" id="ly000"> 
  <单元 name="你好" type="dy" id="dy001"> 
     <留言 name="Who are you" type="zs" id="zs005"> 
        什么是ASP 
        cxx 
        2001-02-20 
        ASP:Active Server Page 
      
     <留言 name="你好" type="zs" id="zs006"> 
        什么是ASP 
        cxx 
        2001-02-20 
        ASP:Active Server Page 
      
   
  <单元 name="我的留言" type="dy" id="dy003"/> 
 
<留言簿 name="留言簿" type="ly" id="ly001"/> 
 
bianli.asp文件

<% @LANGUAGE=VBScript%> 
<% 
function getimgstr(ttid,ttname,ttlvl,tttype,ttlf,ttlstr) 
   dim ttstr1 
   if ttlvl=0 then 
         ttstr1=ttstr1 & "         ttstr1=ttstr1 & " onclick=" & chr(34) & "call OnClickDiv('" & ttid & "','" & "2" & "')"  
         ttstr1=ttstr1 & chr(34) & ">"  
         ttstr1= ttstr1 & "         ttstr1= ttstr1 & "image/Computer.gif" & chr(34) & " height=16>" & "" 
         ttstr1=ttstr1 & "         ttstr1=ttstr1 & " onclick=" & chr(34) & "call OnClickDiv('" & ttid & "','" & "2" & "')" 
         ttstr1=ttstr1 & chr(34) & ">"  
         ttstr1=ttstr1 & ttname & "
" & vbcrlf 
         ttstr1=ttstr1 & "" & vbcrlf 
   else 
      for i= 2 to len(ttlstr)-1 
         if mid(ttlstr,i,1)="1" then 
            ttstr1 = ttstr1 & "            ttstr1 = ttstr1 & "image/I-line.gif" & chr(34) & " height=16>" 
         end if 
         if mid(ttlstr,i,1)="0" then 
            ttstr1 = ttstr1 & "            ttstr1 = ttstr1 & "image/none.gif" & chr(34) & " height=16>" 
         end if 
      next 
      if tttype=1 then 
         ttstr1= ttstr1 & "         ttstr1=ttstr1 & " onclick=" & chr(34) & "call OnClickDiv('" & ttid & "','" & ttlf & "')" 
         ttstr1=ttstr1 & chr(34) & ">"  
         ttstr1=ttstr1 & "         if ttlf=0 then 
            ttstr1= ttstr1 & "image/T-plus.gif" & chr(34) & " id=" & chr(34) & "l-" & ttid & chr(34) & "  
height=16>" 
         else 
            ttstr1= ttstr1 & "image/l-plus.gif" & chr(34) & " id=" & chr(34) & "l-" & ttid & chr(34) & "  
height=16>" 
         end if 
         ttstr1= ttstr1 & "         ttstr1=ttstr1 & " onclick=" & chr(34) & "call OnClickDiv('" & ttid & "','" & ttlf & "')" 
         ttstr1=ttstr1 & chr(34) & ">"  
         ttstr1=ttstr1 & "         ttstr1= ttstr1 & "image/c-fold.bmp" & chr(34) & " id=" & chr(34) & "p-" & ttid & chr(34) & "  
height=16>" 
         ttstr1= ttstr1 & "         ttstr1=ttstr1 & " onclick=" &chr(34) & "call OnClickDiv('" & ttid & "','" & ttlf & "')" 
         ttstr1=ttstr1 & chr(34) & ">"  
         ttstr1=ttstr1 & ttname & "
" & vbcrlf 
         ttstr1=ttstr1 & "" & vbcrlf 
      else 
         ttstr1 = ttstr1 & "         if ttlf=0 then 
            ttstr1 = ttstr1 & "image/t-line.gif" & chr(34) & " height=16>" 
         else 
            ttstr1 = ttstr1 & "image/l-line.gif" & chr(34) & " height=16>" 
         end if 
         ttstr1= ttstr1 & "         ttstr1=ttstr1 & " onclick=" & chr(34) & "call OnClickDiv('" & ttid & "','3')" 
         ttstr1=ttstr1 & chr(34) & ">"  
         ttstr1=ttstr1 & "         ttstr1= ttstr1 & "image/leaf.bmp " & chr(34) & " id=" & chr(34) & "p-" & ttid & chr(34) & "  
height=16>" 
         ttstr1= ttstr1 & "         ttstr1=ttstr1 & " onclick=" & chr(34) & "call OnClickDiv('" & ttid & "','3')" 
         ttstr1=ttstr1 & chr(34) & ">"  
         ttstr1=ttstr1 & ttname & "
" & vbcrlf 
         ttstr1=ttstr1 & "
" & vbcrlf 
      end if 
   end if  
   getimgstr=ttstr1  
end function 
Function ShowNode(node,mylvl,myleaf,mylstr) 
   dim ttstr 
   dim mystr  
   dim ttleaf 
   dim ttn 
   ttn=0 
   if myleaf=0 then 
      ttleaf=0 
   else 
      ttleaf=1 
   end if 
For Each child In node.childNodes 
    ttn=ttn+1 
    If (child.nodeType=1) Then  
       nod_name=child.Attributes.getnamedItem("name").Text  
       nod_type=child.Attributes.getnamedItem("type").Text 
       nod_id=child.Attributes.getnamedItem("id").Text 
       if nod_type<>"zs" then 
          If (child.hasChildNodes) Then 
             if ttn=node.childnodes.length then 
                mystr=mystr & getimgstr(nod_id,nod_name,mylvl,1,1,mylstr & "0") 
                ttstr=ShowNode(child,mylvl+1,1,mylstr & "0") 
             else 
                mystr=mystr & getimgstr(nod_id,nod_name,mylvl,1,0,mylstr & "1") 
                ttstr=ShowNode(child,mylvl+1,0,mylstr & "1") 
             end if 
             mystr=mystr & ttstr 
             mystr=mystr & "" 
          else 
             if ttn=node.childnodes.length then 
                mystr=mystr & getimgstr(nod_id,nod_name,mylvl,0,1,mylstr & "0") 
             else 
                mystr=mystr & getimgstr(nod_id,nod_name,mylvl,0,0,mylstr & "1") 
             end if 
          End If 
       else 
          if ttn=node.childnodes.length then 
             mystr=mystr & getimgstr(nod_id,nod_name,mylvl,0,1,mylstr & "0") 
          else 
             mystr=mystr & getimgstr(nod_id,nod_name,mylvl,0,0,mylstr & "1") 
          end if 
       end if 
    end if 
Next 
ShowNode=mystr 
End Function 
  dim xmldoc 
  dim xmlstr 
  Set xmldoc = Server.CreateObject("Microsoft.XMLDOM") 
  xmldoc.async=false 
  xmldoc.load(Server.MapPath("knowledge.xml")) 
  xmlstr=ShowNode(xmldoc,0,0,"") 
'  set xmldoc=nothing 
'parent.results.display(source.transformNode(style)); 
%> 
 

 
 

 
 
 
<%=xmlstr%> 

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
晓枫资讯-科技资讯社区-免责声明
免责声明:以上内容为本网站转自其它媒体,相关信息仅为传递更多信息之目的,不代表本网观点,亦不代表本网站赞同其观点或证实其内容的真实性。
      1、注册用户在本社区发表、转载的任何作品仅代表其个人观点,不代表本社区认同其观点。
      2、管理员及版主有权在不事先通知或不经作者准许的情况下删除其在本社区所发表的文章。
      3、本社区的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,举报反馈:点击这里给我发消息进行删除处理。
      4、本社区一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
      5、以上声明内容的最终解释权归《晓枫资讯-科技资讯社区》所有。
http://bbs.yzwlo.com 晓枫资讯--游戏IT新闻资讯~~~

  离线 

TA的专栏

等级头衔

等級:晓枫资讯-列兵

在线时间
0 小时

积分成就
威望
0
贡献
0
主题
3
精华
0
金钱
61
积分
25
注册时间
2022-12-23
最后登录
2023-4-27

发表于 2025-3-1 23:26:02 | 显示全部楼层
顶顶更健康!!!
http://bbs.yzwlo.com 晓枫资讯--游戏IT新闻资讯~~~

  离线 

TA的专栏

等级头衔

等級:晓枫资讯-列兵

在线时间
0 小时

积分成就
威望
0
贡献
0
主题
0
精华
0
金钱
16
积分
12
注册时间
2022-12-26
最后登录
2022-12-26

发表于 2025-4-10 20:57:16 | 显示全部楼层
路过,支持一下
http://bbs.yzwlo.com 晓枫资讯--游戏IT新闻资讯~~~
严禁发布广告,淫秽、色情、赌博、暴力、凶杀、恐怖、间谍及其他违反国家法律法规的内容。!晓枫资讯-社区
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1楼
2楼
3楼

手机版|晓枫资讯--科技资讯社区 本站已运行

CopyRight © 2022-2025 晓枫资讯--科技资讯社区 ( BBS.yzwlo.com ) . All Rights Reserved .

晓枫资讯--科技资讯社区

本站内容由用户自主分享和转载自互联网,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。

如有侵权、违反国家法律政策行为,请联系我们,我们会第一时间及时清除和处理! 举报反馈邮箱:点击这里给我发消息

Powered by Discuz! X3.5

快速回复 返回顶部 返回列表