hta实现的笨狼树状节点查看器_hta教程-查字典教程网
hta实现的笨狼树状节点查看器
hta实现的笨狼树状节点查看器
发布时间:2017-01-07 来源:查字典编辑
摘要: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"></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学习
    脚本专栏子分类