The Clumsy Wolf tree node viewer _hta

Source: Internet
Author: User
Tags chr gettext xpath
<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> Stupid Wolf tree node viewer </title>
<body>
<input type= "file" Id=file1 name=file1> Please enter the XML file path
<input type= "button" value= "OK" onclick = "Vbs:analyse" >
<select id= "Select1" onchange= "Vbs:analyse" >
<option value= "NodeName" > Display label </OPTION>
<option value= "Text" > Display text </OPTION>
<option value= "attribute" > Display Properties </OPTION>

<option value= "XPath" > Display xpath</option>
</SELECT>
<div id= "olist" style= "padding-left:0" ></DIV>

</body>
<script language= "VbScript" >
'**************************************
' * * * Author: Super Big Stupid wolf 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 "The file failed to load, please check if the file exists!" "
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 ' indent 10 pixels

childID = 0
Childxpath = Mydiv.getattribute ("XPath") & "& Mychild.nodename &" ["& childID &"] "

Do, 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 ' child elements have not been marked yet.

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 ' all child elements are marked.
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 = "Empty Text"
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 (+) & ""
Next
GetText = Trim (getText)
End If


Case "XPath"
GetText = Odiv.title
End Select
If trim (getText) = "" Then GetText = "Empty"
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>
Xmltool.hta

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.