Click here to Skip to main content
15,921,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a root node and its child nodes. Kindly tell me how to find the children of each child node.

Thanks in advance.
Posted
Updated 21-Oct-11 3:24am
v2

You need to loop through all nodes and their child nodes.
C#
private void CheckChildren(TreeNode node)
{
	foreach (TreeNode n in node.Nodes) {
		n.Checked = node.Checked;
		CheckChildren(n);
	}
}

Passing root node to this function will mark all the nodes as checked/unchecked. You can code it as per your need.
 
Share this answer
 
Hi,

Check this..

My Xml File is

<?xml version="1.0" encoding="UTF-8" ?>
- <Settings>
<Server>SQLEXPRESS</Server>
<Authentication>Integrated Authentication</Authentication>
<Login />
<Password />
<DefaultDatabase>tempTest</DefaultDatabase>
<TableName>mstbl_sms1</TableName>
<PoolingTime>2</PoolingTime>
<Retry>4</Retry>
<ConString>Data Source=SQLEXPRESS;Initial Catalog=tempTest;User Id=;Password=;Integrated Security=SSPI;</ConString>
</Settings>

and i'll fetching for inner nodes..
for using following code.

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("Config.xml");
XmlNodeList dataNodes = xmlDoc.SelectNodes("/Settings");
foreach (XmlNode node in dataNodes)
{
ConString = node.SelectSingleNode("ConString").InnerText;
TableName = node.SelectSingleNode("TableName").InnerText;
}

try it
 
Share this answer
 
Comments
bilawal121 21-Oct-11 8:22am    
Sir I have no knowlegde about xml, i am doing this task on Windows Form C#

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