c# - XElement: a collection of all the leaves? -


How to obtain a collection of all the leaves of a XElement tree, regard the hierarchy? Thanks

What is the way you are after?

This all descendants - to get only the leaves, you get a where section:

  element.Descendants () With LINQ can use the object. (Desc = & gt ;! Des.Elements (.) Anyone ());  

(Note that this is still the only element, not other nodes like text node. Hope is ok.)


Comments