关闭

XML到TreeView的Function

531人阅读 评论(1) 收藏 举报
    Private Function XmlToTree(ByVal Node As XmlNode, ByVal TreeNode As Microsoft.Web.UI.WebControls.TreeNodeCollection)
        If Node.NodeType = XmlNodeType.Text Then
            Dim tNode As New Microsoft.Web.UI.WebControls.TreeNode
            tNode.Text = Node.Value
            TreeNode.Add(tNode)
        ElseIf Node.NodeType = XmlNodeType.Element Then
            Dim Name As String
            Name = Node.Name.ToString
            If Node.Attributes.Count > 0 Then
                Name = Name + "("
                For Each Attr As XmlAttribute In Node.Attributes
                    Name = Name + Attr.Name + "=" + Attr.Value.ToString + " "
                Next
                Name = Name + ")"
            End If
            Dim tNode1 As New Microsoft.Web.UI.WebControls.TreeNode
            tNode1.Text = Name
            TreeNode.Add(tNode1)
            For Each Node1 As XmlNode In Node.ChildNodes
                XmlToTree(Node1, tNode1.Nodes)
            Next
        End If
    End Function
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:5087次
    • 积分:97
    • 等级:
    • 排名:千里之外
    • 原创:5篇
    • 转载:1篇
    • 译文:0篇
    • 评论:1条
    文章存档
    最新评论
    中国下载站