I have a process that uses an XmlReader. I have already done a lot to squeeze maximum performance out of it. So far we have had huge gains from using the Reader as opposed to XmlDoc or DataSet.GetXml(). We expect to get XML many times a second and I would like to avoid the overhead of recreating the reader every time. I have already cached the XmlReaderSettings but is there anyway to reuse the XmlReader or do I need to recreate it every time?
Share
It might be possible to reuse the XmlReader by using some trick, but you shouldn’t. It’s intended for one time use only, so it doesn’t have any means for restarting itself using a different source.
To try to reuse it would probably be more work than creating a new reader anyway. Creating the reader is rather cheap, and hardly something that would be a performance problem.