Craig Davis

Craig Davis

  • NA
  • 40
  • 0

Streamreader out of memory exception parsing XML document

Aug 12 2013 2:12 PM
I have a 80MB XML file that has no carriage returns.  I would like to find the count of an element within the document.  The following code:

StreamReader reader = File.OpenText(file.xml);

string
contents = reader.ReadToEnd();

MatchCollection matches1 = Regex.Matches(contents, "<element>");

count1 = matches1.Count;


produces an out of memory exception error for contents string . 

Any suggestions?


Answers (1)