Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I need to work with a treeview and a xml schema that is to have a scheme that I generate classes for working with a treeview so that then can generate different xml regardless of the values, but needs to work that is object oriented with classes, if someone has an idea thank you.
Posted
Updated 3-Mar-11 9:25am
v2
Comments
Sergey Alexandrovich Kryukov 3-Mar-11 15:51pm    
What do you want to present in the tree: 1) schema, 2) XMLs compliant with the schema, 3) something else?
--SA
Member 13777615 21-Aug-18 8:24am    
schema and xml tree both

1 solution

HI,
Actually i m trying same thing for my upcomming project. Various ways u could do this.
Method 1:
use xmlwriter to create document... I created method GetNode(treenode n)...
Its just reverse of using xml to fill treeview
Although its not perfect solution for me either.
.-----------------------------------------
MemoryStream ms = new MemoryStream();
XMLwriter = new XmlTextWriter(ms, System.Text.Encoding.UTF8);
XMLwriter.WriteStartDocument();
XMLwriter.Formatting = Formatting.Indented;
XMLwriter.WriteStartElement(myTreeview.Nodes[0].Text);
for (int i = 0; i < myTreeview.Nodes[0].GetNodeCount(false); i++)
{
XMLwriter.WriteElementString(myTreeview.Nodes[0].Text,myTreeview.Nodes[0].Nodes[i].Text);
GetNode(myTreeview.Nodes[0].Nodes[i]);
}
XMLwriter.WriteFullEndElement();
XMLwriter.Flush();
then write content of ms in file using streamwriter
Method 2:
Not yet tried but i think this should work..
Use for loop to iterate through all nodes..
create respective xmltags in memory stream..
same as above method but here i create xmltags manually not using xmlwriter. Eg:
ms.write("<"+ treeview.node[].. +">");
to end
ms.write("");
.--------------------------------------------
I hope i was helpfull...i m just started to work on it.. and will post to code if i get solution..
 
Share this answer
 

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