If you already use check boxes in your tree view, you can use the property
Checked
.
Like
foreach (TreeNode node in tnc)
{
if (node.Nodes.Count > 0)
{
if (node.Nodes.Checked)
continue;
}
}
As stated in Solution 1, you should use XmlWriter or even
XDocument [
^](LINQ)
The benefit you get is that you don't have to bother about writing < and > explicitly.
And it will be much easier to create a well formed XML document.
Read the documentation and you will soon see the light.