Export (0) Print
Expand All

XmlAttributes.XmlIgnore Property

Gets or sets a value that specifies whether or not the XmlSerializer serializes a public field or public read/write property.

Namespace:  System.Xml.Serialization
Assembly:  System.Xml (in System.Xml.dll)

member XmlIgnore : bool with get, set

Property Value

Type: System.Boolean
true if the XmlSerializer must not serialize the field or property; otherwise, false.

By default, all public fields and public read/write properties are serialized by the XmlSerializer. That is, the value of each public field or property is persisted as an XML element or XML attribute in an XML-document instance.

To override the default serialization of a field or property, create an XmlAttributes object, and set its XmlIgnore property to true. Add the object to an XmlAttributeOverrides object and specify the type of the object that contains the field or property to ignore, and the name of the field or property to ignore.

If an XmlIgnoreAttribute is applied to a field or property, the field or property is ignored. However you can override that behavior by creating an XmlAttributes object, setting its XmlIgnore property to false, adding it to an XmlAttributeOverrides object specifying the type of the object that contains the field or property, and the name of the field or property.

The following example serializes a class named Group, which contains a member named Comment to which the XmlIgnoreAttribute is applied. The example creates an XmlAttributes object, and sets the XmlIgnore property to false, thereby overriding the XmlIgnoreAttribute.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft