The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XmlRootAttribute.IsNullable Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets a value that indicates whether the XmlSerializer must serialize a member that is set to null into the xsi:nil attribute set to true.

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

public bool IsNullable { get; set; }

Property Value

Type: System.Boolean
true if the XmlSerializer generates the xsi:nil attribute; otherwise, false.

The XML schema specification for structures allows an XML document to explicitly signal that an element's content is missing. Such an element contains the attribute xsi:nil set to true. For more information, see the specification, XML Schema Part 1: Structures.

If the IsNullable property is set to true, the xsi:nil attribute is generated as shown in the following XML.

 <?xml version="1.0" encoding="utf-8"?>
 <Group xmlns:xsi="" 
 xmlns:xsd="" xsi:nil="true" />

If the IsNullable property is false, an empty element is created as shown in the following code.

 <?xml version="1.0" encoding="utf-8"?>
 <Group xmlns:xsi="" 
 xmlns:xsd="" />

The following example serializes a class named Group. The example applies the XmlRootAttribute to the class, and sets the IsNullable property to false.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone