XmlElement::IsEmpty Property
Gets or sets the tag format of the element.
Assembly: System.Xml (in System.Xml.dll)
Property Value
Type: System::BooleanReturns 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 ); }
Available since 10
.NET Framework
Available since 1.1