EDN Admin
Well-known member
Hi all,<br/> <br/> I am serializing a class to XML using the XmlSerializer and I need to be able to exclude NULL properties. I dont have access to the class or its properties so am unable to give it the required attributes.<br/> <br/> Is it possible to prevent NULL class properties from serialized at the serialization level?<br/> <br/> The code I have currently is...<br/> <br/>
<pre lang="x-c# // Serialise to the XML document
var detailDocument = new XmlDocument();
var nav = detailDocument.CreateNavigator();
if (nav != null)
{
using (XmlWriter writer = nav.AppendChild())
{
var ser = new XmlSerializer(objCompany.GetType());
ser.Serialize(writer, objCompany);
}
}[/code]
<br/> Thanks<hr class="sig Tryst
View the full article
<pre lang="x-c# // Serialise to the XML document
var detailDocument = new XmlDocument();
var nav = detailDocument.CreateNavigator();
if (nav != null)
{
using (XmlWriter writer = nav.AppendChild())
{
var ser = new XmlSerializer(objCompany.GetType());
ser.Serialize(writer, objCompany);
}
}[/code]
<br/> Thanks<hr class="sig Tryst
View the full article