tags:

views:

29

answers:

2

Hi,

I want to get child elements from XElement using C#.

Thanks,

+2  A: 

Try .Elements() :

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

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

Kobi
+1  A: 

There are a few alternatives to navigate from an XElement to its children:

IEnumerable<XElement> allChildElements = xElement.Elements();
IEnumerable<XElement> specificChildElements = xElement.Elements("tag");
XElement firstSpecificChildElement = xElement.Element("tag");
Martin Liversage