最佳答案
使用标准时。NETXMLSerializer,有没有什么方法可以隐藏所有的空值?下面是我的类的输出示例。如果可空整数被设置为 null,我不想输出它们。
当前 XML 输出:
<?xml version="1.0" encoding="utf-8"?>
<myClass>
<myNullableInt p2:nil="true" xmlns:p2="http://www.w3.org/2001/XMLSchema-instance" />
<myOtherInt>-1</myOtherInt>
</myClass>
我想要的:
<?xml version="1.0" encoding="utf-8"?>
<myClass>
<myOtherInt>-1</myOtherInt>
</myClass>