How to get specific element Count in XML or XElement variable
问题 Consider this XML: <Employees> <Person> <ID>1000</ID> <Name>Nima</Name> <LName>Agha</LName> </Person> <Person> <ID>1001</ID> <Name>Ligha</Name> <LName>Ligha</LName> </Person> <Person> <ID>1002</ID> <Name>Jigha</Name> <LName>Jigha</LName> </Person> <Person> <ID>1003</ID> <Name>Aba</Name> <LName>Aba</LName> </Person> </Employees> I declare a XElement variable and create the XML assigning it to that. How I can get count of ID elements in this XML variable in C#? 回答1: You can filter the