xml文件数据如下:
<?xml version="1.0" encoding="gb2312"?>
<RTX_Dept>
<Item DeptID="1" PDeptID="0" DeptName="开发部门" SortID="1" Version="1" />
<Item DeptID="2" PDeptID="1" DeptName="基础开发部" SortID="1" Version="2" />
<Item DeptID="3" PDeptID="2" DeptName="产品组" SortID="1" Version="4" />
<Item DeptID="4" PDeptID="1" DeptName="高级开发部" SortID="2" Version="5" />
<Item DeptID="5" PDeptID="4" DeptName="科研组" SortID="1" Version="7" />
<Item DeptID="6" PDeptID="1" DeptName="无线开发部" SortID="3" Version="8" />
<Item DeptID="7" PDeptID="6" DeptName="server组" SortID="1" Version="10" />
<Item DeptID="8" PDeptID="0" DeptName="市场部门" SortID="2" Version="11" />
<Item DeptID="9" PDeptID="8" DeptName="市场拓展部" SortID="1" Version="13" />
<Item DeptID="10" PDeptID="0" DeptName="蓝鸟" SortID="3" Version="16" />
</RTX_Dept>
我想用vb6.0的treeview控件将它以树状层层显示出来,不知道怎么做,如果哪位高手愿意帮忙的话请给出全代码,因为之前我已得到一个不全的代码,琢磨了许久也没搞出来。
不全的代码出下:
'函数已测试OK
Private Function GetValue(ByVal MKey As String, ByVal iStr As String) As String
On Error GoTo er
ar = Split(iStr, MKey)
iStr = ar(1) '右侧字串
ar = Split(iStr, Chr(34))
GetValue = ar(1)
er:
End Function '处理示例
Private Sub Command1_Click()
'示例
XMLFile = "D:\Test.xml" '测试文件名
Open XMLFile For Input As 1
Do Until EOF(1)
Line Input #1, tmp
DeptName = GetValue("DeptName", tmp) '部门名
PDeptID = GetValue("PDeptID", tmp) '父层次ID
SortID = GetValue("SortID", tmp) 'ID
If DeptName <> "" Then
'列表处理,请自己添加代码
'可以用Treeview控制根据上面得到的层次处理
End If
Loop
Close 1
End Sub
我就是不知道“'列表处理,请自己添加代码
'可以用Treeview控制根据上面得到的层次处理 ”这儿怎么写才能把所有的数据显示出来。高手请帮帮我啊,先在此谢过!
<?xml version="1.0" encoding="gb2312"?>
<RTX_Dept>
<Item DeptID="1" PDeptID="0" DeptName="开发部门" SortID="1" Version="1" />
<Item DeptID="2" PDeptID="1" DeptName="基础开发部" SortID="1" Version="2" />
<Item DeptID="3" PDeptID="2" DeptName="产品组" SortID="1" Version="4" />
<Item DeptID="4" PDeptID="1" DeptName="高级开发部" SortID="2" Version="5" />
<Item DeptID="5" PDeptID="4" DeptName="科研组" SortID="1" Version="7" />
<Item DeptID="6" PDeptID="1" DeptName="无线开发部" SortID="3" Version="8" />
<Item DeptID="7" PDeptID="6" DeptName="server组" SortID="1" Version="10" />
<Item DeptID="8" PDeptID="0" DeptName="市场部门" SortID="2" Version="11" />
<Item DeptID="9" PDeptID="8" DeptName="市场拓展部" SortID="1" Version="13" />
<Item DeptID="10" PDeptID="0" DeptName="蓝鸟" SortID="3" Version="16" />
</RTX_Dept>
我想用vb6.0的treeview控件将它以树状层层显示出来,不知道怎么做,如果哪位高手愿意帮忙的话请给出全代码,因为之前我已得到一个不全的代码,琢磨了许久也没搞出来。
不全的代码出下:
'函数已测试OK
Private Function GetValue(ByVal MKey As String, ByVal iStr As String) As String
On Error GoTo er
ar = Split(iStr, MKey)
iStr = ar(1) '右侧字串
ar = Split(iStr, Chr(34))
GetValue = ar(1)
er:
End Function '处理示例
Private Sub Command1_Click()
'示例
XMLFile = "D:\Test.xml" '测试文件名
Open XMLFile For Input As 1
Do Until EOF(1)
Line Input #1, tmp
DeptName = GetValue("DeptName", tmp) '部门名
PDeptID = GetValue("PDeptID", tmp) '父层次ID
SortID = GetValue("SortID", tmp) 'ID
If DeptName <> "" Then
'列表处理,请自己添加代码
'可以用Treeview控制根据上面得到的层次处理
End If
Loop
Close 1
End Sub
我就是不知道“'列表处理,请自己添加代码
'可以用Treeview控制根据上面得到的层次处理 ”这儿怎么写才能把所有的数据显示出来。高手请帮帮我啊,先在此谢过!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货