How to group xml element values
XDocument.Descandants("Customer").GroupBy(c=>c.Element("ServiceId"));
This is not working.
Is there any way to group this?
How to group xml element values
XDocument.Descandants("Customer").GroupBy(c=>c.Element("ServiceId"));
This is not working.
Is there any way to group this?
Assuming that ServiceId is a child element of Customer at your Xml, you can group your customers by ServiceId's value by :
XDocument.Descandants("Customer")
.GroupBy(c=>c.Element("ServiceId").Value);
If ServiceId is an attribute of Customer element, try this :
XDocument.Descandants("Customer")
.GroupBy(c=>c.Attribute("ServiceId").Value);