views:

204

answers:

3

Is there a way to get XmlSerialization in .NET to ignore certain properties while serializing?

For example, I have a public bool Property called IsValid and its the only Property of the object that I don't want serialized. How could I do this?

+5  A: 

Add the XmlIgnoreAttribute over the property.

David Morton
A: 

Use XmlIgnoreAttribute.

MichaelGG
+2  A: 

Just apply [XmlIgnore] to the property you want to ignore.

See http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlattributes.xmlignore.aspx.

Antony Perkov