public void TreeViewToXml(TreeView treeView, String path)
{ xmlDocument = new XmlDocument();
TreeNodeCollection nodes= null ;
foreach (TreeNode treeNode in treeView.Nodes)
{xmlDocument.AppendChild(xmlDocument.CreateElement(treeNode.Text));
nodes = treeNode.Nodes;
} XmlExport(xmlDocument.DocumentElement, nodes);
xmlDocument.Save(path);
} private XmlNode XmlExport(XmlNode nodeElement, TreeNodeCollection treeNodeCollection)
{ XmlNode xmlNode = null;
foreach (TreeNode treeNode in treeNodeCollection)
{
xmlNode = xmlDocument.CreateElement(treeNode.Text);
string[] node = xmlNode.Name.Split(':'); if (node[0] == "ATTRIBUTE")
{ if (node[0] != null && node[1] != null)
{ XmlAttribute newAttribute = xmlDocument.CreateAttribute(node[1]);
nodeElement.Attributes.Append(newAttribute);
}
} else
{
if (nodeElement != null)nodeElement.AppendChild(xmlNode);
} if (treeNode.Nodes.Count > 0)
{
XmlExport(xmlNode, treeNode.Nodes);
}
} return xmlNo