I have an XML in below format. This XML is assigned to an XDocument object.
<root>
<event>
<command>A1</command>
</event>
<event>
<command>B1</command>
</event>
<event>
<command>A1</command>
</event>
<event>
<command>C1</command>
</event>
</root>
I need to fetch the Node Value for all <command> nodes and the number of times each of them occur. In the above case, my desired output would be
A1 2
B1 1
C1 1
I also need the above results to go into object as below
var cmdList=from appinfo in doc.Root.Elements()
select new
{
Cname= ...
CCount =...
}