2

Are there any known dictionary implementations in C# that space efficiently persists itself as XML.

  • It should support generics
  • it may assume that all elements inserted are of the generic type (ie. no subtype is inserted) - Hence the type information can be written once, rather than for each key-value pair.
Carlo V. Dango
  • 13,322
  • 16
  • 71
  • 114
  • possible duplicate of [Why isn't there an XML-serializable dictionary in .NET?](http://stackoverflow.com/questions/1124597/why-isnt-there-an-xml-serializable-dictionary-in-net) – SwDevMan81 May 19 '11 at 14:40
  • space efficient XML is compressed XML (not XML per se, but it is the standard approach) – sehe May 19 '11 at 14:41
  • I dont want the type Information to be persisted again and again as it is done in the so-called duplicate link above. – Carlo V. Dango May 19 '11 at 21:35

1 Answers1

1

Like I said,

space efficient XML is compressed XML (not XML per se, but it is the standard approach)

Consider using compression. In a webserver setting, most browsers support gzip encoding transparently out of the box. So this applies to your garden-variety XML Ajax responses as well


Otherwise, implement IXmlSerializable Interface so you can control exactly how things are serialized.

I remember seeing a number of nice articles, e.g.

  1. How to Implement IXmlSerializable Correctly
  2. Cannot find the 'good' article (my a wellknown MVP community person... don't remember right now. Chris Sells?) Here is an alternative article combining LINQ-to-XML with IXmlSerializable
sehe
  • 374,641
  • 47
  • 450
  • 633
  • Its not for a webserver but storing data in a DB. I have a look at the links although an actual implementation would have been nice :) – Carlo V. Dango May 19 '11 at 21:41