Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
IsEmpty Property

XElement::IsEmpty Property

Gets a value indicating whether this element contains no content.

Namespace:  System.Xml.Linq
Assemblies:   System.Xml.Linq (in System.Xml.Linq.dll)
  System.Xml.XDocument (in System.Xml.XDocument.dll)

public:
property bool IsEmpty {
	bool 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 />
True

<Root>content</Root>
False

<Root></Root>
False

<Root />
True

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft