我正在寻找如何统计XML文件中包含值“否”以及元素总数的节点。如何统计包含特定值的XML节点数
我有元素计数工作正常,但我不确定的逻辑来查看XML的内部计数值。
要获得总计数我使用:
XmlDocument readDoc = new XmlDocument();
readDoc.Load(MapPath("Results.xml"));
int count = readDoc.SelectNodes("root/User").Count;
lblResults.Text = count.ToString();
下面是我的XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<root>
<User>
<URL>http://www.example.com</URL>
<JSEnabled>Yes</JSEnabled>
</User>
<User>
<URL>http://www.example.com</URL>
<JSEnabled>Yes</JSEnabled>
</User>
<User>
<URL>http://www.example.com</URL>
<JSEnabled>Yes</JSEnabled>
</User>
<User>
<URL>http://www.example.com</URL>
<JSEnabled>Yes</JSEnabled>
</User>
<User>
<URL>http://www.example.com</URL>
<JSEnabled>No</JSEnabled>
</User>
这让我了解了我所要求的内容,但在阅读完参考链接后,我得到了更多的信息,然后我就开始寻找。非常感谢 – InsertOldUserIDHere 2011-01-10 20:24:47