简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

hta实现的笨狼树状节点查看器

来源:易贤网   阅读:869 次  日期:2016-06-24 10:52:57

温馨提示:易贤网小编为您整理了“hta实现的笨狼树状节点查看器”,方便广大网友查阅!

<html>

<head>

<style>

table

{

    border-collapse: collapse;

    border-width: 4; 

    border-style: double; 

    border-color:#15336f;

    font-size:12px;

}

body

{

    font-size:12px;

}

div

{

    width:100%;

    height:9; 

    border-style:solid; 

    border-width:1; 

    border-color:#eeeeee;    

    vertical-align:top;

    font-size:12;

    cursor:hand;

}

</style>

<title>笨狼树状节点查看器</title>

</head>

<body>

 <input type=file id=file1 name=file1>请输入xml文件路径

 <input type=button value=确定 onclick = vbs:analyse >

 <select id=select1 onchange=vbs:analyse>

        <option value=nodename >显示标签</option>

        <option  value=text >显示文字</option>

        <option  value=attribute >显示属性</option>

        <option  value=xpath >显示xpath</option>

</select>

<div id=olist style=padding-left:0></div>

</body>

 <script language=vbscript >

    '**************************************

    '****作者:    超级大笨狼 superdullwolf****

    '**************************************        

        public dic,favour,anything    ,doc      

        set doc = createobject(microsoft.xmldom)        

        doc.async=false

    sub analyse()

            dim mytr 

            favour = select1.value

            removediv  

            if not doc.load(file1.value) then 

                alert 文件加载失败,请检查文件是否存在!    

            else

                set rootnode = doc.documentelement

                set rootdiv = document.createelement(div)    

                rootdiv.setattribute xpath,rootnode.nodename 

                olist.setattribute xpath,rootnode.nodename                  

                olist.setattribute parsed,false

                appenddiv     olist,rootnode    

            end if

    end sub

    sub appenddiv(mydiv,mynode)    

        dim mychild    ,newdiv,childid,thisid ,childxpath

        for each mychild in mynode.childnodes

            if     mychild.nodename <> #text    then    

                set newdiv = document.createelement(div)            

                mydiv.appendchild    newdiv            

                addpx newdiv, mydiv,10    '缩进10象素

                childid = 0

                childxpath = mydiv.getattribute(xpath) & / & mychild.nodename & [ & childid & ]    

                do while not doc.selectsinglenode(childxpath) is mychild

                    childid=childid+1

                    childxpath = mydiv.getattribute(xpath) & / & mychild.nodename & [ & childid & ]    

                loop

                newdiv.setattribute xpath,childxpath 

                newdiv.setattribute parsed,false    '子元素还没标记过了。

                newdiv.title = newdiv.getattribute(xpath) 

                newdiv.innertext = gettext(mychild,newdiv) 

                if mychild.childnodes.length>0 then 

                        newdiv.attachevent onclick,getref(attachonclick)

                end if

            end if                     

        next

        mydiv.setattribute parsed,true'所有子元素都标记过了。

    end sub    

    sub removediv()             

        dim olddiv

        for each  olddiv in   olist.childnodes          

               olddiv.removenode(true)             

         next     

    end sub

    sub attachonclick()

        dim obj    ,nodexpath,cdiv

        set obj=window.event.srcelement 

        nodexpath = obj.getattribute(xpath)

        if instr(nodexpath,#text) >0 then 

            window.event.cancelbubble = true

            exit sub

        end if

        if not obj.getattribute(parsed)= true then     

             appenddiv obj ,doc.selectsinglenode(nodexpath)

        else

            for each cdiv in obj.children

                if cdiv.style.display = none then

                    cdiv.style.display = 

                else

                    cdiv.style.display = none

                end if

            next

        end if

        window.event.cancelbubble = true         

    end sub

    function gettext(mynode,odiv)

        dim myattribute

        gettext = 

        select case favour

            case text

                if not isnull(mynode.text) then

                    gettext = mynode.text

                 else

                    gettext = 空文字

                 end if            

            case nodename                 

                    gettext = mynode.nodename    

            case attribute    

                if mynode.nodename <>#text then

                    for each myattribute in  mynode.attributes                         

                        gettext =gettext &  myattribute.name

                        gettext = gettext & = & chr(34) 

                        gettext = gettext & myattribute.value  & chr(34) &  

                    next

                    gettext = trim(gettext)

                end if

            case xpath

                gettext = odiv.title

        end select

        if trim(gettext) = then gettext =空

    end function

    sub addpx(newdiv,olddiv,num)

        dim re,mystring    

        set re = new regexp

        re.global = true

        re.pattern = [^\d]*            

        mystring =  re.replace(olddiv.style.paddingleft, )

        if mystring = then mystring = 0

        mystring = (cint(mystring) + num ) & px

        newdiv.style.paddingleft = mystring

        set re = nothing

    end sub

 </script>

</html>

更多信息请查看网络编程
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:javascript代码应该放在html代码哪个位置比较好
下一篇:js实现简单鼠标跟随效果的方法
易贤网手机网站地址:hta实现的笨狼树状节点查看器
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!