OutOfMemory exception when loading xml in C#

I am assuming that your xml file is to big to be handled by the XmlTextReader. (Because XmlTextReader will try to read the whole xml file at once)

You could try a SAX parser which does a sequential parsing. See http://en.wikipedia.org/wiki/Simple_API_for_XML

See http://saxdotnet.sourceforge.net/

for a c# solution. As far as I know there is no native .net framework sax parser solution. Maybe anyone else does know a newer sax parser for .net? I am very interested 🙂

Leave a Comment