'函数已测试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控制根据上面得到的层次处理 '如果不知道处理Treeview请直接发百度消息或QQ58507961 End If Loop Close 1 End Sub