다음을 통해 공유


XmlElement.IsEmpty 속성

요소의 태그 형식을 가져오거나 설정합니다.

네임스페이스: System.Xml
어셈블리: System.Xml(system.xml.dll)

구문

‘선언
Public Property IsEmpty As Boolean
‘사용 방법
Dim instance As XmlElement
Dim value As Boolean

value = instance.IsEmpty

instance.IsEmpty = value
public bool IsEmpty { get; set; }
public:
property bool IsEmpty {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_IsEmpty ()

/** @property */
public void set_IsEmpty (boolean value)
public function get IsEmpty () : boolean

public function set IsEmpty (value : boolean)

속성 값

요소를 짧은 태그 형식 "<item/>"으로 serialize할 경우 true를 반환하고, 긴 형식 "<item></item>"으로 serialize할 경우 false를 반환합니다. 이 속성을 설정할 때 true로 설정하면 요소의 자식이 제거되고 요소는 짧은 태그 형식으로 serialize됩니다. false로 설정하면 요소에 내용이 있는지 여부와 상관없이 속성 값이 변경되고, 요소가 비었으면 긴 형식으로 serialize됩니다. 이 속성은 DOM(문서 개체 모델)에 대한 Microsoft 확장입니다.

설명

이 속성은 DOM(문서 개체 모델)의 Microsoft 확장입니다.

예제

다음 예제에서는 빈 요소에 내용을 추가합니다.

Imports System
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
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);

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

public class Sample
{
    public static void main(String[] args)
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<book>"
            + "<title>Pride And Prejudice</title>"
            + "<price/>"
            + "</book>");

        XmlElement currNode = 
            (XmlElement)doc.get_DocumentElement().get_LastChild();
        if (currNode.get_IsEmpty()) {
            currNode.set_InnerXml("19.95");
        }

        Console.WriteLine("Display the modified XML...");
        Console.WriteLine(doc.get_OuterXml());
    } //main 
} //Sample

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

XmlElement 클래스
XmlElement 멤버
System.Xml 네임스페이스