File this under stuff I should have known...
If you only need read-only access to an XML file, using the XmlReader is much, Much, MUCH faster than loading the file into an XmlDocument object and performing XPath selects.
I have recently been working on a project where I was doing some off-brand serialization/deserialization of objects. Initially I was simply loading the file into an XmlDocument and doing my node selects. I had roughly 80 megabytes in 100 XML files and the performance wasn't where I wanted to be.
After doing a bit of research I found that, Duh! the XmlDocument is slow. I adjusted my code to use an XmlReader for reading the XML files and XmlWriter for saving out the serialized XML.
The results went from 1 minutes, 8 seconds to load using XmlDocument to 8 seconds using XmlReader.
...I should have known this...
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5