Get child elements from XElement

CRK picture CRK · Aug 26, 2010 · Viewed 82k times · Source

Possible Duplicate:
Children of XElement

I want to get child elements from XElement using C#. How can this be done?

Answer

Kobi picture Kobi · Aug 26, 2010

Try .Elements() :

XElement element = GetElement();
var children = element.Elements();

If you want elements from all levels, you may also have a look at Descendants.