XmlElement.IsEmpty Özellik

Tanım

Öğesinin etiket biçimini alır veya ayarlar.

public:
 property bool IsEmpty { bool get(); void set(bool value); };
public bool IsEmpty { get; set; }
member this.IsEmpty : bool with get, set
Public Property IsEmpty As Boolean

Özellik Değeri

Boolean

trueöğe "item/" kısa etiket biçiminde< seri hale getirilecekse, false "<item/>item><>" uzun biçimi için.

Bu özellik ayarlanırken, olarak ayarlanırsa trueöğesinin alt öğeleri kaldırılır ve öğe kısa etiket biçiminde serileştirilir. olarak ayarlanırsa false, özelliğin değeri değiştirilir (öğenin içeriği olup olmadığına bakılmaksızın); öğe boşsa, uzun biçimde serileştirilir.

Bu özellik, Belge Nesne Modeli(DOM) için bir Microsoft uzantısıdır.

Örnekler

Aşağıdaki örnek boş bir öğeye içerik ekler.

#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 );
}
using System;
using System.Xml;

public class Sample {

  public static void Main() {

      XmlDocument doc = new XmlDocument();
      doc.LoadXml("<book>"+
                  "  <title>Pride And Prejudice</title>" +
                  "  <price/>" +
                  "</book>");

      XmlElement currNode = (XmlElement) doc.DocumentElement.LastChild;
      if (currNode.IsEmpty)
        currNode.InnerXml="19.95";

      Console.WriteLine("Display the modified XML...");
      Console.WriteLine(doc.OuterXml);
  }
}
 Imports System.Xml

public class Sample

  public shared sub Main()
  
      Dim doc as XmlDocument = new XmlDocument()
      doc.LoadXml("<book>" & _
                  "  <title>Pride And Prejudice</title>" & _
                  "  <price/>" & _
                  "</book>")   

      Dim currNode as XmlElement 
      currNode = CType (doc.DocumentElement.LastChild, XmlElement)
      if (currNode.IsEmpty)
        currNode.InnerXml="19.95"
      end if

      Console.WriteLine("Display the modified XML...")
      Console.WriteLine(doc.OuterXml)

  end sub
end class

Açıklamalar

Bu özellik, Belge Nesne Modeli'nin (DOM) bir Microsoft uzantısıdır.

Şunlara uygulanır