hta實(shí)現(xiàn)的笨狼樹(shù)狀節(jié)點(diǎn)查看器
發(fā)布日期:2021-12-22 00:16 | 文章來(lái)源:源碼之家
<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>笨狼樹(shù)狀節(jié)點(diǎn)查看器</title>
</head>
<body>
<INPUTtype="file"id=file1name=file1>請(qǐng)輸入xml文件路徑
<INPUTtype="button"value="確定"onclick="vbs:analyse">
<SELECTid="select1"onchange="vbs:analyse">
<OPTIONvalue="nodeName">顯示標(biāo)簽</OPTION>
<OPTIONvalue="text">顯示文字</OPTION>
<OPTIONvalue="attribute">顯示屬性</OPTION> <OPTIONvalue="XPath">顯示XPath</OPTION>
</SELECT>
<DIVid="oList"style="padding-left:0"></DIV> </body>
<scriptlanguage="vbScript">
'**************************************
'****作者:超級(jí)大笨狼superdullwolf****
'************************************** publicdic,favour,anything,doc setdoc=CreateObject("Microsoft.XMLDOM")
doc.async=False
subanalyse()
dimmyTR
favour=select1.value
removeDIV
ifnotdoc.load(file1.value)then
alert"文件加載失敗,請(qǐng)檢查文件是否存在!"
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'縮進(jìn)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'子元素還沒(méi)標(biāo)記過(guò)了。 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'所有子元素都標(biāo)記過(guò)了。
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
<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>笨狼樹(shù)狀節(jié)點(diǎn)查看器</title>
</head>
<body>
<INPUTtype="file"id=file1name=file1>請(qǐng)輸入xml文件路徑
<INPUTtype="button"value="確定"onclick="vbs:analyse">
<SELECTid="select1"onchange="vbs:analyse">
<OPTIONvalue="nodeName">顯示標(biāo)簽</OPTION>
<OPTIONvalue="text">顯示文字</OPTION>
<OPTIONvalue="attribute">顯示屬性</OPTION> <OPTIONvalue="XPath">顯示XPath</OPTION>
</SELECT>
<DIVid="oList"style="padding-left:0"></DIV> </body>
<scriptlanguage="vbScript">
'**************************************
'****作者:超級(jí)大笨狼superdullwolf****
'************************************** publicdic,favour,anything,doc setdoc=CreateObject("Microsoft.XMLDOM")
doc.async=False
subanalyse()
dimmyTR
favour=select1.value
removeDIV
ifnotdoc.load(file1.value)then
alert"文件加載失敗,請(qǐng)檢查文件是否存在!"
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'縮進(jìn)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'子元素還沒(méi)標(biāo)記過(guò)了。 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'所有子元素都標(biāo)記過(guò)了。
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>

版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
相關(guān)文章