使用.NET XmlSerializer进行反序列化时,请使用多个根命名空间

时间:2015-05-21 14:00:27

标签: .net xml serialization

我的问题非常像one。但是,我需要在同一个根目录中允许两个不同的命名空间。

类似的东西:

    [XmlType(Namespace = "")]
[XmlRoot("included_parameters", Namespace = "http://apif.freescale.net/schemas/paramdef/1.0")]
[XmlRoot("included_parameters", Namespace = "http://apif.freescale.net/schemas/paramdef/1.1")]
public class IncludedParameters
{
}

基本上,我想将模式的1.1版架构的xml文件反序列化为相同的.net类。

如果您需要更多详细信息,请与我们联系。

克里斯

1 个答案:

答案 0 :(得分:0)

有一个SerializationBinder类让一个人进行这种类型的转换操作。

https://msdn.microsoft.com/en-us/library/system.runtime.serialization.serializationbinder%28v=vs.110%29.aspx

"Some users need to control which class to load, either because the class has moved between assemblies or a different version of the class is required on the server and client"