Reputation: 762
In other words, is XMLDocument more efficient than XmlReader to validate a well formed xml document? from a memory prospective if you have a large XML file and used XMLDocument you might end with out of memory exception.
Upvotes: 0
Views: 397
Reputation: 17010
To expand on your answer a bit, it depends on what you are trying to do. If this is truly just validating, then XmlDocument is probably the correct version, as it has to complete load to validate. The reader is a "firehose cursor" of sorts that streams the data as you read it. When you have a reader, reading to end will validate. May be a bit faster, but a bit more code.
Upvotes: 0
Reputation: 762
That is the answer I was looking for it was provided in a comment by @canton7 XmlReader is a low-level streaming API. XmlDocument is a higher-level API built on top of XmlReader. Using the level which is appropriate: maybe you want an easier-to-use convenient API, or maybe you want to write lots of code to use the more efficient streaming API
Upvotes: 1