|
|
|
Click here to copy the following block |
Sub DisplayXmlFile(ByVal filename As String, ByVal tvw As TreeView) Dim xmldoc As New XmlDocument() xmldoc.Load(filename) DisplayXmlNode(xmldoc, tvw.Nodes) tvw.Nodes(0).Expand() End Sub
Sub DisplayXmlNode(ByVal xmlnode As XmlNode, ByVal nodes As TreeNodeCollection) Dim tvNode As TreeNode = nodes.Add(xmlnode.Name)
Select Case xmlnode.NodeType Case XmlNodeType.Element If xmlnode.Attributes.Count > 0 Then Dim attrNode As TreeNode = tvNode.Nodes.Add("(ATTRIBUTES)") Dim xmlAttr As XmlAttribute For Each xmlAttr In xmlnode.Attributes attrNode.Nodes.Add(xmlAttr.Name & " = '" & xmlAttr.Value & _ "'") Next End If Case XmlNodeType.Text, XmlNodeType.CDATA tvNode.Text = xmlnode.Value Case XmlNodeType.Comment tvNode.Text = "<!--" & xmlnode.Value & "-->" Case XmlNodeType.ProcessingInstruction, XmlNodeType.XmlDeclaration tvNode.Text = "<?" & xmlnode.Name & " " & xmlnode.Value & "?>" Case Else End Select
Dim xmlChild As XmlNode = xmlnode.FirstChild Do Until xmlChild Is Nothing DisplayXmlNode(xmlChild, tvNode.Nodes) xmlChild = xmlChild.NextSibling Loop End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|