XDocument + IEnumerable is causing out of memory exception in System.Xml.Linq.dll
See the question and my original answer on StackOverflowIf processed XML files are too big (around 500-800M) than you cannot use XDocument (or XmlDocument either) because it will try to load the whole document in memory. See this discussion: Does LINQ handle large XML files? Getting OutOfMemoryException
In this case, you should rather use a XStreamingElement Class and build your ContainerClass from it.
Maybe going to a 64-bit process would help, but the best practise is always to use streaming from end to end.