阿狮阿狮

阿狮吗

XML到TreeView的Function
    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
阅读更多
文章标签: function xml each string
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

XML到TreeView的Function

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭