在C#中如何计算所有XML标签? [英] In C# how to count all the XML tags?
本文介绍了在C#中如何计算所有XML标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请告知我如何使用C#计数文档中的所有XML标记.
Please advise how do I count all the XML tags in a document using C#.
推荐答案
鉴于doc是XDocument的一个实例
Given that doc is an instance of XDocument
doc.Root.Descendants().Count(d => (string)d.Attribute("attName") == "value");
这篇关于在C#中如何计算所有XML标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文