更新时间:2023-12-05 21:41:16
试试这个,
Hi,
try this,
var count = XDocument
.Load("test.xml")
.XPathSelectElements("//submenuid")
.Count();
你知道吗, XmlNodeList.Count [ ^ ],对吧?
XmlDocument.GetElementsByTagName [ ^ ]返回一个XmlNodeList,其中包含所有后代元素的列表匹配指定的名称。
请参阅给定链接上的示例。 :)
-KR
You know this, XmlNodeList.Count[^], right ??
XmlDocument.GetElementsByTagName[^] returns an XmlNodeList containing a list of all descendant elements that match the specified name.
See the examples on given links. :)
-KR