Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,


How to Export Dynamic TreeView To xml in ASP.NET

Pls Help....
Posted
Comments
NITHIN INDIA 12-Apr-11 3:08am    
In WEB Application

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Apr-11 3:15am    
Helpful, my 5.
--SA
Abhinav S 12-Apr-11 9:53am    
Thank you.
Check this article it might help Save a TreeView into an XML File[^]
Regards
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Apr-11 3:15am    
At the same time with Abhinav? 5, too.
--SA
Ciumac Sergiu 12-Apr-11 3:25am    
Yeap :) I haven't see Abhinal solution (didn't refresh the page).
Only export, not export/import? This is really simple but requires one more input: XML schema and mapping between the TreeView data and this schema.

Everything is easy: traverse in a loop the root nodes using System.Web.UI.WebControls.TreeView.Node, for each node call some recursive function which writes the node properties in the XML (or DOM) and call the same function for child nodes.

See this code for example: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/8e6db1e6-e429-4b4f-9ac6-5e848604188b/[^].

For XML you can use System.Xml.XmlTextWriter, System.Xml.XmlDocument (it implements DOM, is the simplest to use but only good for relatively small amount of data) or System.Xml.Linq.XDocument.

—SA
 
Share this answer
 
v2
Comments
Abhinav S 12-Apr-11 9:53am    
Good comment. My 5.
Sergey Alexandrovich Kryukov 12-Apr-11 10:59am    
Thank you, Abhinav.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900