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)

'Declaration
Public ReadOnly Property IsEmpty As Boolean

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.


Dim output As New StringBuilder
Dim el1 As XElement = <Root/>
output.Append(el1)
output.Append(Environment.NewLine)
output.Append(el1.IsEmpty)
output.Append(Environment.NewLine)
Dim el2 As XElement = <Root>content</Root>
output.Append(el2)
output.Append(Environment.NewLine)
output.Append(el2.IsEmpty)
output.Append(Environment.NewLine)
Dim el3 As XElement = <Root></Root>
output.Append(el3)
output.Append(Environment.NewLine)
output.Append(el3.IsEmpty)
output.Append(Environment.NewLine)
el3.ReplaceAll(Nothing)
output.Append(el3)
output.Append(Environment.NewLine)
output.Append(el3.IsEmpty)
output.Append(Environment.NewLine)


OutputTextBlock.Text = output.ToString()


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: