如何检查子节点的子节点 [英] How to check child's of child node

查看:78
本文介绍了如何检查子节点的子节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个根节点及其子节点.请告诉我如何找到每个子节点的子节点.

预先感谢.

I have a root node and its child nodes. Kindly tell me how to find the children of each child node.

Thanks in advance.

推荐答案

您需要遍历所有节点及其子节点.
You need to loop through all nodes and their child nodes.
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.


您好,

检查一下.

我的Xml文件是

<?xml version ="1.0" encoding ="UTF-8"吗?>
-<设置>
<服务器> SQLEXPRESS</服务器>
<认证>集成认证</认证>
<登录/>
<密码/>
< DefaultDatabase> tempTest</DefaultDatabase>
< TableName> mstbl_sms1</TableName>
< PoolingTime> 2</PoolingTime>
< Retry> 4</Retry>
< ConString>数据源= SQLEXPRESS;初始目录= tempTest;用户ID =;密码=;集成安全性= SSPI;</ConString>
</设置>

然后我将获取内部节点..
用于使用以下代码.

XmlDocument xmlDoc =新的XmlDocument();
xmlDoc.Load("Config.xml");
XmlNodeList dataNodes = xmlDoc.SelectNodes("/Settings");
foreach(dataNodes中的XmlNode节点)
{
ConString = node.SelectSingleNode("ConString").InnerText;
TableName = node.SelectSingleNode("TableName").InnerText;
}

试试吧
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


这篇关于如何检查子节点的子节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆