Reading large XML documents in .net

You basically have to use the “pull” model here – XmlReader and friends. That will allow you to stream the document rather than loading it all into memory in one go.

Note that if you know that you’re at the start of a “small enough” element, you can create an XElement from an XmlReader, deal with that using the glory of LINQ to XML, and then move onto the next element.

Leave a Comment