From the course: .NET Essentials: LINQ for XML

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Get child elements

Get child elements - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

Get child elements

- We've seen that calling the elements method returns and I innumerable of X element. In this case it's returning all the seven cards that are children of the collectibles root element. If I continue calling .elements, what do you think will happen? Now here, I'm calling .elements on the cards and I'm looking for one of his children element. This slogan is a child of card but I'm asking for the elements. So I'm getting back another I innumerable of X element. So how's that going to be handled? Let's take a look. I get back seven items. There's seven cards. I got back seven X elements. This time the X element is the slogan element only. So this is one way that we start filtering the information that's in the file. I can navigate through the tree and pull out a collection of data for what I need in this case just the slogan elements. Let's continue this concept. And at this time I'll look for monster. I'll look for…

Contents