Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

export of a treeview to xml

Status
Not open for further replies.

231166

Programmer
Apr 5, 2005
104
FR
Hi,

i have created a treeview and have created a code to export it to xml format.
Now i would like to give a user to export the part of the treeview he has choiced to xml format.
In fact, by 'part' i mean from a root , it means from each first level of the treeview.
For example, if the treeview is constructed like this

1
2
3
4



5
6
7
8

The number 1 and 5 are the root of the treeview; if the user clicks on the level 1 or 5 he can see all the level below( it means 2 , 3 and 4).
I can telle you that the level one has a tag which form is "MT"+number and all the level below have a tag which form is "GT"+number.
the code i have for the moment is this one
Code:
Private Sub ExportTreeviewToXml(ByVal TreeView As TreeView, ByVal OutputPath As String)

        'open a file stream and wrap it with an XmlTextWriter 
        'ouvrez un flux pour en faire un futur fichier situé dans le chemin préciséet enveloppez le d'un XmlTextWriter
        Dim clsStream As System.IO.FileStream = System.IO.File.Create(OutputPath)


        Dim clsWriter As New System.Xml.XmlTextWriter(clsStream, System.Text.Encoding.UTF8)
        clsWriter.Formatting = Xml.Formatting.Indented

        ' start document... 
        clsWriter.WriteStartDocument()
        clsWriter.WriteStartElement("TreeView")

        'use a recursive function to write out the tree nodes as Xml nodes. 
        Call ExportTreeviewNodesToXml(TreeView.Nodes, clsWriter)

        'close writer / stream... 
        clsWriter.WriteEndElement()
        clsWriter.Flush()
        clsWriter.Close()
        'clsStream.Dispose()

    End Sub
If you could help me on this point it would be very kind from you.

Best regards.

Nathalie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top