将treeview中节点数据保存为嵌套格式XML文档
Public Sub TNodeToXml(trvw As TreeView, Optional NodeK As String, Optional Tabs As String = "")
Dim i As Integer, k As Integer
Dim NodekT As String
Dim StrOver As String
If Len(NodeK) = 0 Then
NodeK = trvw.Nodes(1).key
If Dir(CurrentProject.Path & "\tt.xml") <> "" Then Kill CurrentProject.Path & "\tt.xml"
Open CurrentProject.Path & "\tt.xml" For Output As #1
Print #1, "<?xml version=""1.0"" encoding=""GB2312"" ?>"
Print #1, "<Node Label=""" & trvw.Nodes(1).text & """>"
End If
k = trvw.Nodes(NodeK).Children
For i = 1 To k
If i = 1 Then
NodekT = trvw.Nodes(NodeK).Child.key
Else
NodekT = trvw.Nodes(NodekT).Next.key
End If
If trvw.Nodes(NodekT).Children = 0 Then StrOver = "/" Else StrOver = ""
Print #1, Tabs & vbTab & "<Node Label=""" & trvw.Nodes(NodekT).text & """" & StrOver & ">"
Call TNodeToXml(trvw, NodekT, Tabs & vbTab)
Next i
If k > 0 Then Print #1, Tabs & "</Node>"
If NodekT = trvw.Nodes(1).Child.LastSibling.key Then Close #1
End Sub
---------------------
调用时
Call TNodeToXml(trvw.Object) '注 trvw 为 你所要导出的treeview控件名
(责任编辑:admin)
- ·关于 Partition 函数在分组查询中的应
- ·Access算术运算符的含义和说明表
- ·mid函数的另类用法
- ·access制作程序运行进度框
- ·Function与Sub的异同(函数调用)
- ·Access判断某个数值是否为某个数据类型
- ·select case后面语句块的值的四种格式
- ·vba条件语句的两种表示方法
- ·Access几种数据类型初始化的值
- ·Access vba null与""空字符串的区别
- ·access vba 数据类型表
- ·Access变量的命名规则
- ·Access中EXIT Sub与End Sub的区别
- ·Access vba中参数前关键字ByRef和ByVal
- ·Access列表框快速全选的技巧【最快】
- ·vba函数的数据类型强制转换