score:48
Accepted answer
Just document.Root.Elements()
should work.
Basically Descendants()
recurses, whereas Elements()
only gets direct children.
Source: stackoverflow.com
Related Query
- How to get first level of children by LINQ
- How to get first record in each group using Linq
- How to get first object out from List<Object> using Linq
- How to get SQL query into LINQ form in C# code
- How to get children data from json via linq
- C# LINQ How to get a data source from a db?
- How do I get the first value from this collection using Linq to Entities?
- How to flatten a multi level XML into a single level XML using c# code LINQ
- How to get PEX to automatically generate inputs for code involving LINQ
- How do I get first element of each array via Linq C#
- Using Linq lambdas, how can I get the first item in a two-key-sorted list?
- How to use LINQ to get the first matching file from inside a ZipArchive?
- How to get multiple level deep line items using linq in c#?
- How to get a count of all children lists, grandchildren lists, great grandchildren lists etc. in Linq
- how to write a Linq query with a EF code first Many to Many relationship
- How to get record form a different table based on a value from first table with linq expression?
- how to select data by linq in many-to-many relationship in First code Entity framework 5
- How to LINQ Query Code First generated EF6 hierarchical entities (entities within entities)?
- How to dynamically create linq code at runtime and get results
- Does Linq in Entity Framework code first use SQL or does it get the whole table first?
- How to sort by a specific key and then get the first result in the sorted collection into a group in LINQ
- C# linq how to get all the first elements of a nested dynamic list?
- C# LINQ or for loop How to get a data source from a db?
- How to get a sum of children values on one LINQ
- How to get the list of employees and their reporting level recursively using LINQ
- how to get first object when the name is the same and Id is different with linq query
- How to get the first descendant of a node without knowing the name from XML using LINQ
- How to get results from another query list if first linq query returns empty?
- How to call an Sql User defined Function using Entity frame work Code first approach with LInq c#
- How to return just first parent element, but many children and grandchildren in Linq with Entity Framework - SYBASE ASE Connector bug
More Query from same tag
- Turn Function or Stored Procedure Result into "live" Result for LINQ
- What should you use for joining in LINQ, Query syntax or method syntax?
- Using Field<> with Linq to SQL
- Linq using StartsWith always empty
- Splitting a string that is a property of an object, creating new objects from the split strings. Is there an elegant way?
- How can I use linq to authenticate username/password?
- FirstOrDefault() result of a struct collection?
- Linq to XML Find a an attribute and return seperate attribute value
- Does using the extension method ToList<T>() waste resources?
- Make my textbox view result from a LINQ query
- How to Bind a group by data in view in mvc5? what are the best ways to do
- LINQ "zip" in String Array
- Better way of assigning the variable during LINQ Query
- Dynamically composing LINQ expressions
- Joins and subqueries in LINQ
- How do I access an anonymous object's properties outside its scope?
- find records by criteria and select only one if they have some equal field (LINQ)
- Is LINQ's Any method efficient?
- How to get an EF query to compile the most optimised SQL?
- Linq OrderBy to group objects with the same sets
- Check null values in Linq query in Entity Framework
- MVC Joining many 2 many tables and filling list based on result in c#
- dynamic linq queries in linq-to-entities
- Compare items in different dictionaries with same key using LINQ
- Iterate with LINQ over a list and set founded varible
- Refactor LINQ method to introduce Lamba function as a parameter
- Linq to XML get item with id in id collection
- Order a list of lists in C# using LINQ
- How to return ILookup directly (without using a Dictionary->ILookup converter)
- SequenceEqual linq group