Tuesday, March 7, 2006

I was mentioned by Scott, or XmlReader vs. Others...

Originally posted on: http://geekswithblogs.net/meshel/archive/2006/03/07/71593.aspx

I encountered this post by Scott Hanselman (whom I of course read regularly), and was mentioned in his after-post - WoooHooo!!! I love attention, even got a link back... Just kidding, I feel unworthy, I just tried putting in my two cents, and didn't think it was such a contribution.

To the point, of course Scott is right, XmlReader is much more efficient than XmlDocument (I'm not going into this read his post), also I agree about the Nametable usage, I also wondered but I answered myself (and Scott explains it better) obviously comaring pointers is faster than comparing strings and pointers... By creating a dummy object with the needed information and comparing that - you let the faster comparison to work.

Anyway obviously using XmlReader correctly (as Scott suggests) is probably faster and more efficient than using XPathReader (since XPathReader is a wrapper around XmlReader, and it is not optimized for your query).

As usual it burns down to what you need your application to do, in the case described XmlReader is probably the best option.