How big is the speed difference between XPathNavigator and XmlReader?

I have a rather large XML file that I need to parse in the structure of the .NET class (for displaying in a fixed-length format and transmitting via MQ). Performance is important, but not absolutely critical.

I almost always use XPathNavigatorXML files to read, because it's a lot easier than that XmlReader. On the other hand, I know that it’s XmlReaderfaster than XPathNavigatorbecause it theoretically just reads one node at a time, while it XPathNavigatorshould read enough to run XPath, possibly the entire document.

My question is: how much faster is it really? Will it make a noticeable difference when reading a few thousand nodes? What is the turning point when I have to switch to XmlReader? Or is it XPathNavigatoroptimized to such an extent that it is always a good option?

Most of my XML experience is with relatively small files, so I'm looking for information from those who have worked with large files.

+5
source share
1 answer

As far as I know, the only places where you can get the XPathNavigator implementation is either the .Xml.Linq.XDocument file or the XPathDocument file, both of which contain the entire tree in memory.

XmlReader, , XML .

, , , XmlReader XPathNavigator , : -

  • XML ,
  • .
+5

All Articles