views:

128

answers:

1

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 http://stackoverflow.com/questions/751511/validating-an-xml-against-referenced-xsd-in-c for validation procedure.

thanks, Mark

+1  A: 

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
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
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