0

If I have a large (>500MB) XML file to validate, does an XmlReader bring the whole thing into memory to perform validation?

I looked at Validating an XML against referenced XSD in C# for validation procedure.

thanks, Mark

Community
  • 1
  • 1
MStodd
  • 4,716
  • 3
  • 30
  • 50

1 Answers1

1

No, if you use XmlValidatingReader (or XmlReader with appropriate settings) it won't load the whole XML file. The method described in the question uses XmlDocument class which does load the whole file. The accepted answer doesn't load the entire file so you'll be fine using it.

Mehrdad Afshari
  • 414,610
  • 91
  • 852
  • 789
  • Can you please explain which XmlReader settings should be used to ensure that we don't have the entire 500+ MB xml in memory during validation? – MStodd May 15 '09 at 20:19
  • No specific settings. I meant appropriate settings to turn on validation. XmlReader doesn't load the whole document in general. However, you should enable validation if you want (as described in the answer). – Mehrdad Afshari May 15 '09 at 20:21