如何使用C#将字典对象序列化为XML文件

问题描述:

我有一个包含所有值的字典对象.现在,我想将其序列化为xml文件.

I have a dictionary object with all the values.  Now, I wanted to serialize it into an xml file.

由于xmlserializer不支持字典,因此我使用了datacontractserializer,并且我还通过使用来处理未知类型 DataContractResolver.  

Since dictionary is not supported with xmlserializer, I have used datacontractserializer and i have also handled unknown types by using DataContractResolver. 

这里的问题是,我得到的输出如下.

The issue here is, I am getting the output as below.

但是我需要生成如下输出:

But I need to generate the output as below:

  

  

Vis

WCF论坛
The WCF forums http://social.msdn.microsoft.com/Forums/en-US/wcf/threads is the better place for such questions