XmlNode.RemoveChild(XmlNode) 메서드

정의

지정된 자식 노드를 제거합니다.

public:
 virtual System::Xml::XmlNode ^ RemoveChild(System::Xml::XmlNode ^ oldChild);
public virtual System.Xml.XmlNode RemoveChild (System.Xml.XmlNode oldChild);
abstract member RemoveChild : System.Xml.XmlNode -> System.Xml.XmlNode
override this.RemoveChild : System.Xml.XmlNode -> System.Xml.XmlNode
Public Overridable Function RemoveChild (oldChild As XmlNode) As XmlNode

매개 변수

oldChild
XmlNode

제거할 노드입니다.

반환

XmlNode

제거한 노드입니다.

예외

oldChild가 이 노드의 자식이 아닌 경우 이 노드가 읽기 전용인 경우

예제

다음 예제에서는 XML 문서에서 노드를 제거합니다.

#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 the title element.
   root->RemoveChild( root->FirstChild );
   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 the title element.
    root.RemoveChild(root.FirstChild);

    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 the title element.
        root.RemoveChild(root.FirstChild)
        
        Console.WriteLine("Display the modified XML...")
        doc.Save(Console.Out)
    End Sub
End Class

상속자 참고

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

적용 대상