I am trying to load an XML file into a tree view control, edit it and save it back in a different XML format.
<MyConfig>
<description>
<![CDATA[Add All config data]]>
</description>
<group name="Server">
<description>
<![CDATA[Server info]]>
</description>
<parameter name="Host" type="string">
<description>
<![CDATA[Host Name]]>
</description>
<value>cccc.ac.lk</value>
</parameter>
<parameter name="Port" type="integer">
<description>
<![CDATA[port no]]>
</description>
<range>0-65536</range>
<value>47110</value>
</parameter>
</group>
</MyConfig>
I am using the following method to load the XML data
private void populateTreeControl(System.Xml.XmlNode document,
System.Windows.Forms.TreeNodeCollection nodes)
{
foreach (System.Xml.XmlNode node in document.ChildNodes)
{
string text = (node.Value != null ? node.Value :
(node.Attributes != null && node.Attributes.Count > 0) ?
node.Attributes[0].Value : node.Name);
TreeNode new_child = new TreeNode(text);
nodes.Add(new_child);
populateTreeControl(node, new_child.Nodes);
}
}
Now I want to filter out some nodes and load it to tree view. As an example it is useless for me to load description tags etc in the above case. I just want to create the tree with MyConfig –> Group –> Server—> Host and MyConfig –> Group –> Server—> Port
How should I modify the populateTreeControl() method to gain this?
call as