如何计算 XML 文档中特定节点的子节点? [英] How to count the childnodes for the specific node in the XML document?
本文介绍了如何计算 XML 文档中特定节点的子节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对 C# 比较新鲜.我必须解析 xml 文档,并且必须计算子节点的特定节点.
I'm fresher to c#. i've to parse the xml document and have to count the specific node of the childnodes.
例如:
<Root>
<Id/>
<EmployeeList>
<Employee>
<Id/>
<EmpName/>
</Employee>
<Employee>
<Id/>
<EmpName/>
</Employee>
<Employee>
<Id/>
<EmpName/>
</Employee>
</EmployeeList>
</Root>
在这个xml中,我如何计算员工"节点??
In this xml, how do I count the "Employee" nodes??
如何在 C# 中使用 XmlDocument 类解析并获得解决方案?
How can i parse and get the solution using XmlDocument class in C#?
推荐答案
int Count = doc.SelectNodes("Employee").Count;
这篇关于如何计算 XML 文档中特定节点的子节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文