Windows apps
Collapse the table of content
Expand the table of content
Information
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.

XmlElement::IsEmpty Property

 

Gets or sets the tag format of the element.

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

public:
property bool IsEmpty {
	bool get();
	void set(bool value);
}

Property Value

Type: System::Boolean

Returns true if the element is to be serialized in the short tag format "<item/>"; false for the long format "<item></item>".

When setting this property, if set to true, the children of the element are removed and the element is serialized in the short tag format. If set to false, the value of the property is changed (regardless of whether or not the element has content); if the element is empty, it is serialized in the long format.

This property is a Microsoft extension to the Document Object Model (DOM).

This property is a Microsoft extension of the Document Object Model (DOM).

The following example adds content to an empty element.

#using <System.Xml.dll>

using namespace System;
using namespace System::Xml;
int main()
{
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<book>  <title>Pride And Prejudice</title>  <price/></book>" );
   XmlElement^ currNode = dynamic_cast<XmlElement^>(doc->DocumentElement->LastChild);
   if ( currNode->IsEmpty )
      currNode->InnerXml = "19.95";

   Console::WriteLine( "Display the modified XML..." );
   Console::WriteLine( doc->OuterXml );
}

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft