How to count number of XML nodes that contain specific value

后端 未结 2 681
一整个雨季
一整个雨季 2021-01-19 06:13

I am looking for how to count the nodes in an XML file that contain a value of \"No\" as well as the total number of elements.

I have the element count working fine,

2条回答
  •  悲&欢浪女
    2021-01-19 06:44

    XmlDocument readDoc = new XmlDocument();
    readDoc.Load(MapPath("Results.xml"));
    int count = readDoc.SelectNodes("root/User").Count;
    lblResults.Text = count.ToString();
    int NoCount = readDoc.SelectNodes("JSEnabled[. = \"No\"]").Count;
    

    Good reference here: http://msdn.microsoft.com/en-us/library/ms256086.aspx

提交回复
热议问题