views:

58

answers:

2

I have got an XML document which looks something like this.

<Root>
<Info>....</Info>
<Info>....</Info>
<response>....</response>
<warning>....</warning>
<Info>....</Info>
</Root>

How can i write a LINQ to XML query so that it returns me an IEnumerable containing each child element, in this case all five child elements of , so that i could iterate over them.

The order of child elements is not definite, neither is number of times the may appear.

Thanks in advance.

+1  A: 

You can call the Elements method to get all of the elements directly inside an XElement.
For example:

doc.Root.Elements()
SLaks
A: 

Basically the method Elements() returns IEnumerable<XElement>, is that what you are looking for?

Take a look in msdn though.. http://msdn.microsoft.com/en-us/library/bb308960.aspx

Ekaterina