您可以为.NET序列化的NULL值添加其他属性吗?

时间:2012-03-09 18:42:43

标签: .net serialization nullable xml-nil

在.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"/>

这可能吗?

1 个答案:

答案 0 :(得分:0)

我明白了。这是答案:

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