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 - .NET Tutorial
From the course: .NET Essentials: LINQ for XML
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
-
-
-
-
(Locked)
Get an element from XML2m 33s
-
(Locked)
Get an attribute from XML1m 25s
-
(Locked)
Get nodes when using schema namespace3m 32s
-
(Locked)
Get single or multiple elements2m 27s
-
(Locked)
Get child element1m 12s
-
(Locked)
Get child elements1m 58s
-
(Locked)
Use Descendants() to recurse child elements52s
-
(Locked)
Get attributes51s
-
(Locked)
Read element and attribute values1m 32s
-
(Locked)
Change element and attribute values1m 36s
-
(Locked)
Use SetElementValue to add, remove, and modify child elements1m 37s
-
(Locked)
Use SetValue to set with non-string data1m 4s
-
(Locked)
-
-
-