【问题标题】:Can you add additional properties to .NET serialized NULL values?您可以向 .NET 序列化的 NULL 值添加其他属性吗?
【发布时间】:2012-03-27 05:08:19
【问题描述】:

在 .NET 中,您可以使用 XmlElement( IsNullable = true ) 序列化可为空的元素,结果如下:

<SomeElement xsi:nil="true" />.

但是,我需要能够在任何被清空的字段之后添加 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance。

例子:

<SomeElement xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

这可能吗?

【问题讨论】:

    标签: .net serialization nullable xml-nil


    【解决方案1】:

    我想通了。答案如下:

    [XmlElement(IsNullable = true, Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-08
      • 1970-01-01
      • 1970-01-01
      • 2011-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多