Why (or when) you should/shouldn’t use Descendants() method
30 Aug 2013A lot of LINQ to XML questions on StackOverflow are being answered using Descendants()
method calls. It looks like most of people think it’s the best way to handle and query XML document: it’s easy to use, you don’t have to worry about whole tree structure. It just works. But are these solutions really good ones? Is Descendants()
method really that good as it seems to be? I would say: NO! I think common LINQ to XML queries should not use Descendants()
. I’ll try to answer it shouldn’t be used in this blog post.