Don Demsak (DonXML) has a great posting that compares the relative performance of four ways to stuff an object from the database:
- DataReader
- DataSet
- XPathNavigator
- XmlSerialization
They are in order :-)
Not surprisingly, XmlSerialization is the slowest (by 47%). Something to think about, no?
Don also references a nice anti-DataSet for Web Services post by Scott Hansleman.
A colleague of mine is struggling with how to define his XML vocabulary in XML Schema. Specifically, he is struggling with whether he should define an id attribute on every element. On one hand, IDs are very easy for business type folks to wrap their heads around, as opposed to XPath expressions. Moreover, schema validations are vastly simplified. On the other hand, some implementers are complaining that for various language implementations, there is a large object creation overhead to represent simple elements as objects that contain attributes, just to support the id attribute.
A few thoughts on this:
The bigger question is whether the XmlSerializer should be used at all if performance is an issue to you. Many have written that XmlReader/Writer and XPathDocument are better approaches. [1] In fact Microsoft has reversed the direction and once again beefing up XPathDocument for .NET 2.0 and suggesting that it be used over XmlDocument for writing as well as reading. [2] Finally note that we are encouraged to use XmlElement when passing XML arguments in ASMX 1.x though there are faster ways!
[1] See a great summary of .NET XML technologies by Scott Hanselman here. The BCL 1.x definitive word by Aaron Skonnard here. Don Box on using XPathDocument for argument passing here (video). See Dare's BCL 1.x definitive Best Practices for Representing XML in the .NET Framework.
[2] Aaron Skonnard's PDC 2003 Report explains the move to XPathDocument. Required reading!
Of course I haven't answered the question definitively on which way my colleague should go. However, I think that he can be confident that there are performant ways to handle the plethora of IDs he's contemplating.