I've created an object with 100+ elements and not all of them are showing up in the final XML after serialization. What can I add to the [XmlElement] decorator to make sure it is in the final XML even if it is empty?
A:
You can use:-
[XmlElement(IsNullable = true)]
public string MustBePresent;
However this also includes the xsi namespace and adds xsi:nil = "true"
attribute to the element.
AnthonyWJones
2009-08-25 20:52:31
+1
A:
use the "IsNullable" property
public class Person
{
[XmlElement(IsNullable = true)]
public string Name { get; set; }
}
http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlelementattribute.isnullable.aspx
free-dom
2009-08-25 20:53:14