Brian Noyles blogs about the XPathNavigator, and how it has improved his life.
I spoke last night at the Central Pennsylvania Users Group in Harrisburg, PA. They have a great group and about 35 folks turned out despite snow and nasty weather. Judy Calla is the group lead and gave a nice little beginners talk on debugging and error handling in .NET applications. I then jumped in with a talk on querying XML data in .NET.
The primary function of the XPathNavigator is to act as a common plug-in point for xpath/xslt query processing. It is the query equivalent to the XmlReader. We built the XPathDocument pretty late in the game right before .Net framework 1.0 shipped. It was basically a perf thing. We were beating ourselves up trying to get better perf out of the DOM, but were reaching the limit to what we could do with that model. It was when we realized that most of what was slowing us down was baggage from the DOM like sequences of text nodes and entity expansion, things that had no representation in the XPath model. The XPathDocument is optimized for xpath query because it gets rid of anything that doesn’t fit, so there is no impedence mismatch.
It also didn’t hurt to assign identity to each node in increasing order right a load time. This makes it incredibly fast to keep the nodes straight, especially when wacky coders start using strange axes. Because the XmlDocument was editable, it couldn’t keep a zero cost ordering scheme. Let’s hope the new XPathDocument stays as fast, even with its new editing capability.
See, I can actually post something that links to someone else’s blog. Who knows, yours may be next.