可以将其他属性添加到.NET序列化的NULL值吗? [英] Can you add additional properties to .NET serialized NULL values?
本文介绍了可以将其他属性添加到.NET序列化的NULL值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在.NET中,您可以使用XmlElement(IsNullable = true)序列化可为空的元素,结果是:
In .NET, you can serialize a nullable element using XmlElement( IsNullable = true ), which results in this:
<SomeElement xsi:nil="true" />.
但是,我需要能够在任何被清空的字段之后添加xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance.
However, I need to be able to add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance after any field that is being nulled out.
示例:
<SomeElement xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
这可能吗?
推荐答案
我知道了.答案是这样:
I figured it out. Here is the answer:
[XmlElement(IsNullable = true, Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
这篇关于可以将其他属性添加到.NET序列化的NULL值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文