标题 | 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> |
随便看 |
|
在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。