LINQ to XML and reading large XML files

LINQ to XML makes it relatively easy to read and query XML files. For example consider the following XML file:

Suppose you would like to find all records with groupid > 2. You could be tempted to issue the following query:

There’s a flaw in this method. XElement.Load method will load the whole XML file in memory and if this file is quite big, (more…)