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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

treeview to xml

Status
Not open for further replies.

alecomo

Programmer
Joined
Oct 28, 2005
Messages
4
Location
IT
hi all!
i have a big big problem with my program...
i want to export a treeview to an xml file...
all is quite simple but when i try to export some kind of nodes i find a lot of problems...
my treeview is structured like this:
manifest (it can be only 1)
->orgs (1)
->org (1...n)
for export manifest node and orgs node i dont find any problem
if i try to export the org node i have too much problems!!
i need a recursional function that iterate through org nodes and recursively add them to the xml file...
here is my code
please help meee!!
tnx to all

private void saveNode2(TreeNodeCollection tnc)
{
foreach (TreeNode node in tnc)
{
if (node.Nodes.Count > 0)
{
if (node.Text == "organizations")
{

xr.WriteStartElement(node.Text);
xr.WriteStartAttribute("default_organization");
xr.WriteValue(orgs.p_default_organization);
xr.WriteEndAttribute();
saveNode2(node.Nodes);
xr.WriteEndElement();

}

else if (node.Text == "organization")
{
xr.WriteStartElement(node.Text);
xr.WriteStartAttribute("id_organization");
xr.WriteValue(org.p_id_organization);
xr.WriteEndAttribute();
xr.WriteStartAttribute("struct_organization");
xr.WriteValue("hierarchical");
xr.WriteEndAttribute();
xr.WriteElementString("title", org.p_title_organization);
saveNode2(node.Nodes);
xr.WriteEndElement();
}
}
HELP!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top