tree.htm
<script language="JavaScript" type="text/javascript"></script> <script language="JavaScript" type="text/javascript"></script> <script Language="JavaScript">
var ImgArr = new Array();
var level=0;
var vid=0;
var HTML="";
var img="";
function getSubject()
{
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("tree.xml");
if(xmlDoc.parseError.errorCode != 0)
{
alert(xmlDoc.parseError.reason);
return;
}
else
{
var nodes=xmlDoc.documentElement.childNodes;
for(var i=0;i<nodes.length;i++)
{
img="";
if(nodes(i).nodeName=="tree")
{
vid++;
if(i==nodes.length-1){
ImgArr[level]="<img src='images/L+.gif' id='f"+vid+"' οnclick=divshow('"+vid+"')>";
img=ImgArr[level];
readTree(nodes(i),true);
}
else{
ImgArr[level]="<img src='images/T+.gif' id='f"+vid+"' οnclick=divshow('"+vid+"')>";
img=ImgArr[level];
readTree(nodes(i),false);
}
}
else if(nodes(i).nodeName=="node")
{
img="<img src='images/T.gif'>";
if(i==nodes.length-1)img="<img src='images/L.gif'>";
readNode(nodes(i));
}
}
}
delete(xmlDoc);
window.show.innerHTML=HTML;
return;
}
function readTree(cI,sp)
{
var nodes=cI.childNodes;
var menuHTML=img;
menuHTML+="<img src='images/";
menuHTML+=cI.selectNodes("image")(0).text;
menuHTML+="'>";
menuHTML+="<a href='";
if(cI.selectNodes("link")(0).text!=""){menuHTML+=cI.selectNodes("link")(0).text;}
else{menuHTML+="#";}
if(cI.selectNodes("target")(0).text!="")menuHTML+= "' target='"+cI.selectNodes("target")(0).text;
menuHTML+="' οnclick=javascript:divshow('"+vid+"')";
menuHTML+=" title='";
menuHTML+=cI.selectNodes("title")(0).text;
menuHTML+="'>";
menuHTML+=cI.selectNodes("text")(0).text;
menuHTML+="</a><br>/n";
HTML+=menuHTML;
HTML+="<div id='div"+vid+"' style='display:none'>/n";
ImgArr[level]="<img src='images/i.gif'>";
if(sp)ImgArr[level]="<img src='images/white.gif'>";
for(var i=0;i<nodes.length;i++)
{
level++;
ImgArr[level]="<img src='images/i.gif'>/n";
if(sp)ImgArr[level]="<img src='images/white.gif'>/n";
img="";
var tempImg="";
for(var j=0;j<level;j++)
{
tempImg+=ImgArr[j];
}
img=tempImg;
if(nodes(i).nodeName=="tree")
{
vid++;
if(i==nodes.length-1)
{
img+="<img src='images/L+.gif' id='f"+vid+"' οnclick=divshow('"+vid+"')>";
readTree(nodes(i),true);
}
else
{
img+="<img src='images/T+.gif' id='f"+vid+"' οnclick=divshow('"+vid+"')>";
readTree(nodes(i),false);
}
img="";
}
else if(nodes(i).nodeName=="node")
{
if(i==nodes.length-1)
{
img+="<img src='images/L.gif'>";
}
else{
img+="<img src='images/T.gif'>";
}
readNode(nodes(i));
}
level--;
}
HTML+="</div>/n";
return;
}
function readNode(cI)
{
//alert("ok");
var nodeHTML=img;
nodeHTML+="<img src='images/";
nodeHTML+=cI.selectNodes("image")(0).text;
nodeHTML+="'>";
nodeHTML+="<a href='";
nodeHTML+=cI.selectNodes("link")(0).text;
if(cI.selectNodes("target")(0).text!="")nodeHTML+= "' target='"+cI.selectNodes("target")(0).text;
nodeHTML+="' title='";
nodeHTML+=cI.selectNodes("title")(0).text;
nodeHTML+="'>";
nodeHTML+=cI.selectNodes("text")(0).text;
nodeHTML+="</a><br>/n";
HTML+=nodeHTML;
return;
}
function divshow(vid)
{
if(document.all["div"+vid].style.display=="none"){
document.all["div"+vid].style.display="";
document.all["f"+vid].src=document.all["f"+vid].src.replace("+","-")
}
else{
document.all["div"+vid].style.display="none";
document.all["f"+vid].src=document.all["f"+vid].src.replace("-","+")
}
return;
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
font-size: 9pt;
}
A {
text-decoration:none;
font-family: "宋体";
font-size: 9pt;
COLOR:#000000;
}
img{
vertical-align: text-bottom;
}
-->
</style>
</head>
<body bgcolor="#76b4d9" leftmargin="0" topmargin="0">
<div id=show></div>
</body>
<script>
getSubject()
</script>
</html>
tree.xml
<?xml version="1.0" encoding="gb2312"?>
<treeview>
<tree id="p1">
<text>啊啊</text>
<target>_blank</target>
<title>特殊台</title>
<link>ddd.asp</link>
<image>folder.gif</image>
<node>
<text>并不</text>
<target>_blank</target>
<title>特殊台</title>
<link>zzz.asp</link>
<image>html.gif</image>
</node>
<tree id="p1-1">
<text>常常</text>
<target>_blank</target>
<title>特殊台</title>
<link>yyy.asp</link>
<image>folder.gif</image>
<node>
<text>达到</text>
<target>_blank</target>
<title>特殊台</title>
<link>bbb.asp</link>
<image>html.gif</image>
</node>
<tree id="p1-1">
<text>方法</text>
<target>_blank</target>
<title>特殊台</title>
<link>hhh.asp</link>
<image>folder.gif</image>
<node>
<text>各个</text>
<target>_blank</target>
<title>特殊台</title>
<link>bbb.asp</link>
<image>html.gif</image>
</node>
<tree id="p1-1">
<text>合乎</text>
<target>_blank</target>
<title>特殊台</title>
<link>www.asp</link>
<image>folder.gif</image>
<node>
<text>经济</text>
<target>_blank</target>
<title>特殊台</title>
<link>qqq.asp</link>
<image>html.gif</image>
</node>
<node>
<text>可靠</text>
<target>_blank</target>
<title>特殊台</title>
<link>fff.asp</link>
<image>html.gif</image>
</node>
</tree>
</tree>
<node>
<text>力量</text>
<target>_blank</target>
<title>特殊台</title>
<link>fff.asp</link>
<image>html.gif</image>
</node>
<node>
<text>奶奶</text>
<target>_blank</target>
<title>特殊台</title>
<link>fff.asp</link>
<image>html.gif</image>
</node>
</tree>
</tree>
<tree id="p2">
<text>批评</text>
<target>_blank</target>
<title>特殊台</title>
<link>ooo.asp</link>
<image>folder.gif</image>
<node>
<text>亲切</text>
<target>_blank</target>
<title>特殊台</title>
<link>ccc.asp</link>
<image>html.gif</image>
</node>
<node>
<text>仍然</text>
<target>_blank</target>
<title>特殊台</title>
<link>eee.asp</link>
<image>html.gif</image>
</node>
</tree>
<node>
<text>仍然</text>
<target>_blank</target>
<title>特殊台</title>
<link>eee.asp</link>
<image>html.gif</image>
</node>
<node>
<text>仍然</text>
<target>_blank</target>
<title>特殊台</title>
<link>eee.asp</link>
<image>html.gif</image>
</node>
</treeview>