XmlNode.RemoveAll 메서드

정의

현재 노드의 모든 자식 노드 및/또는 특성을 제거합니다.

public:
 virtual void RemoveAll();
public virtual void RemoveAll ();
abstract member RemoveAll : unit -> unit
override this.RemoveAll : unit -> unit
Public Overridable Sub RemoveAll ()

예제

다음 예제에서는 루트 노드에서 모든 자식 및 특성 노드를 제거합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<book genre='novel' ISBN='1-861001-57-5'>"
   "<title>Pride And Prejudice</title>"
   "</book>" );
   XmlNode^ root = doc->DocumentElement;
   
   //Remove all attribute and child nodes.
   root->RemoveAll();
   Console::WriteLine( "Display the modified XML..." );
   doc->Save( Console::Out );
}
using System;
using System.IO;
using System.Xml;

public class Sample {

  public static void Main() {

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +
                "</book>");

    XmlNode root = doc.DocumentElement;

    //Remove all attribute and child nodes.
    root.RemoveAll();

    Console.WriteLine("Display the modified XML...");
    doc.Save(Console.Out);
  }
}
Option Explicit
Option Strict

Imports System.IO
Imports System.Xml

Public Class Sample
    
    Public Shared Sub Main()
        Dim doc As New XmlDocument()
        doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" & _
                    "<title>Pride And Prejudice</title>" & _
                    "</book>")
        
        Dim root As XmlNode = doc.DocumentElement
        
        'Remove all attribute and child nodes.
        root.RemoveAll()
        
        Console.WriteLine("Display the modified XML...")
        doc.Save(Console.Out)
    End Sub
End Class

설명

제거된 특성에 기본값이 있는 것으로 알려진 경우 기본값을 포함하는 특성이 즉시 나타나고, 해당하는 경우 해당 네임스페이스 URI, 로컬 이름 및 접두사를 포함합니다.

이 메서드는 DOM(문서 개체 모델)에 대한 Microsoft 확장입니다.

상속자 참고

파생 클래스에서 재정의할 RemoveAll 때 이벤트가 올바르게 발생하려면 기본 클래스의 메서드를 RemoveAll 호출해야 합니다.

적용 대상