I've got a fairly big XML file that I need to parse into a .NET class structure (to be mapped to a fixed-length record format and transmitted via MQ). Performance is important, but not absolutely critical.
I almost always use XPathNavigator
to read XML files because it's much easier than XmlReader
. On the other hand, I know XmlReader
is faster than XPathNavigator
, because it theoretically just reads one node at a time whereas XPathNavigator
has to read enough to execute an XPath, possibly the whole document.
My question is: how much faster is it really? Will it make a noticeable difference when reading a few thousand nodes? What's the tipping point where I pretty much have to switch to XmlReader
? Or is XPathNavigator
optimized to the point that it's always a good option?
Most of my XML experience is on relatively small files, so I'm looking for input from anybody who's worked with big files.