手机
当前位置:查字典教程网 >脚本专栏 >hta >hta实现的笨狼树状节点查看器
hta实现的笨狼树状节点查看器
摘要:table{border-collapse:collapse;border-width:4;border-style:double;bord...

<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>

<INPUTtype="file"id=file1name=file1>请输入xml文件路径

<INPUTtype="button"value="确定"onclick="vbs:analyse">

<SELECTid="select1"onchange="vbs:analyse">

<OPTIONvalue="nodeName">显示标签</OPTION>

<OPTIONvalue="text">显示文字</OPTION>

<OPTIONvalue="attribute">显示属性</OPTION>

<OPTIONvalue="XPath">显示XPath</OPTION>

</SELECT>

<DIVid="oList"style="padding-left:0"></DIV>

</body>

<scriptlanguage="vbScript">

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

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

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

publicdic,favour,anything,doc

setdoc=CreateObject("Microsoft.XMLDOM")

doc.async=False

subanalyse()

dimmyTR

favour=select1.value

removeDIV

ifnotdoc.load(file1.value)then

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

else

SetrootNode=doc.DocumentElement

setrootDIV=document.createElement("DIV")

rootDIV.setAttribute"XPath",rootNode.nodeName

oList.setAttribute"XPath",rootNode.nodeName

oList.setAttribute"parsed",false

appendDIVoList,rootNode

endif

endsub

subappendDIV(myDIV,myNode)

dimmyChild,newDIV,ChildID,thisID,ChildXPath

foreachmyChildinmyNode.childNodes

ifmyChild.nodeName<>"#text"then

setnewDIV=document.createElement("DIV")

myDIV.appendChildnewDIV

addPxnewDIV,myDIV,10'缩进10象素

ChildID=0

ChildXPath=myDIV.getAttribute("XPath")&"/"&myChild.nodeName&"["&ChildID&"]"

dowhilenotdoc.selectSingleNode(ChildXPath)ismyChild

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)

ifmyChild.childNodes.length>0then

newDIV.attachEvent"onclick",GetRef("attachOnclick")

endif

endif

next

myDIV.setAttribute"parsed",true'所有子元素都标记过了。

endsub

subremoveDIV()

dimoldDIV

foreacholdDIVinoList.childNodes

oldDIV.removeNode(true)

next

endsub

subattachOnclick()

dimobj,nodeXPath,cDIV

setobj=window.event.srcElement

nodeXPath=obj.getAttribute("XPath")

ifinstr(nodeXPath,"#text")>0then

window.event.cancelBubble=true

exitsub

endif

ifnotobj.getAttribute("parsed")=truethen

appendDIVobj,doc.selectSingleNode(nodeXPath)

else

foreachcDIVinobj.children

ifcDIV.style.display="none"then

cDIV.style.display=""

else

cDIV.style.display="none"

endif

next

endif

window.event.cancelBubble=true

endsub

functiongetText(myNode,oDIV)

dimmyAttribute

getText=""

selectcasefavour

case"text"

ifnotisnull(myNode.text)then

getText=myNode.text

else

getText="空文字"

endif

case"nodeName"

getText=myNode.nodeName

case"attribute"

ifmyNode.nodeName<>"#text"then

foreachmyAttributeinmyNode.attributes

getText=getText&myAttribute.name

getText=getText&"="&chr(34)

getText=getText&myAttribute.value&chr(34)&""

next

getText=trim(getText)

endif

case"XPath"

getText=oDIV.title

endselect

iftrim(getText)=""thengetText="空"

endfunction

subaddPx(newDIV,oldDIV,num)

dimre,myString

setre=newRegExp

re.Global=true

re.Pattern="[^d]*"

myString=re.Replace(oldDIV.style.paddingLeft,"")

ifmyString=""thenmyString="0"

myString=(cint(myString)+num)&"px"

newDIV.style.paddingLeft=myString

setre=nothing

endsub

</script>

</html>

XMLTool.hta

【hta实现的笨狼树状节点查看器】相关文章:

用hta实现的远程桌面连接脚本

hta实现的涂鸦效果

学习正则帮手笨狼正则练习器

hta编写的消费记录程序

vpn连接程序hta版实现代码(修改)

hta实现的二进制文件转换为文本

hta实现的笨狼XSLT练习器

从 HTA 中启动应用程序

如何使一个HTA位于屏幕中心(Win32_DesktopMonitor)

hta 定时关机重启实现代码

精品推荐
分类导航