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.

Use Query syntax to work with elements

Use Query syntax to work with elements - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

Use Query syntax to work with elements

- This is the chapter, where we look at how to use the LINQ Query Operators, and query expressions to query the XML data. Most of the techniques we've seen up to this point are XML specific. We've seen how to get the elements and attributes from the XML tree. We've looked at how to read values from the tree. Write the content to the tree and saved the file. We need these tools to work with XML, but they are not what we need to query the data. Now, what we need to remember is our LINQ skills. When you're working with LINQ to objects we query items that are in an IEnumerable<T>. And in the XML world, we can get an IEnumerable<T> like this. Remember that when I call the elements method I'm getting back an IEnumerable<X> element. So this is my entry into the query syntax. Once I have this, then I can use to query operators. I can use query expressions and all the world of LINQ opens up to what I can do with this data. Right…

Contents