From the course: .NET Essentials: LINQ for XML
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Challenge: Move attributes and elements - .NET Tutorial
From the course: .NET Essentials: LINQ for XML
Challenge: Move attributes and elements
(upbeat music) - [Instructor] It's time for another code challenge. Here's the problem, we're going to look at the contents of WebColorsA.xml, and we're going to take one of the color values, or I should say all the color values that are in there. And I want you to transform them. So, here's what we have for the original. We've got color name and color family as attributes. We've got the hex value, we have red, green, and blue and then we have hue, saturation, and lightness. So, your job is to remove the attributes and turn those into elements, color name element and the color family element. (inhales deeply) You'll leave hex alone, that's going to stay as a child of color. And then, you're going to create a new parent element RGB and a new HSL element. And you're going to move red, green, and blue into the RGB element. And you're going to move hue, saturation and lightness into the HSL element. Now, it's your turn…
Contents
-
-
-
-
-
-
Use the DumpFormatted extension method1m 32s
-
XDocument compared to XElement2m 40s
-
Create XML structure3m 18s
-
Rename elements and attributes1m 49s
-
Replace elements and attributes1m 30s
-
Remove element1m 26s
-
Add parent element and move elements2m 14s
-
Challenge: Move attributes and elements1m 9s
-
Solution: Move attributes and elements2m 31s
-
-