我正在尋找如何統計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