XElement.IsEmpty Property


Gets a value indicating whether this element contains no content.

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

member IsEmpty : bool with get

Property Value

Type: System.Boolean

true if this element contains no content; otherwise false.

Note that an element that contains a start and end tag with no content between the tags is not considered to be an empty element. It has content with no length. Only an element that contains only a start tag, and is expressed as a terminated empty element, is considered to be empty.

The following example creates a variety of XML trees, and shows the value of this property with each tree.

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

This example produces the following output:

                <Root />



<Root />

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top