XContainer.RemoveNodes 메서드

정의

이 문서 또는 요소에서 자식 노드를 제거합니다.

public:
 void RemoveNodes();
public void RemoveNodes ();
member this.RemoveNodes : unit -> unit
Public Sub RemoveNodes ()

예제

다음 예제에서는 일부 자식 노드를 포함하는 XML 트리를 만듭니다. 그런 다음 이 메서드를 호출하여 자식 노드를 제거합니다.

XElement xmlTree = new XElement("Root",  
    new XElement("Child1", 1),  
    new XElement("Child2", 2),  
    new XComment("a comment"),  
    new XElement("Child3", 3),  
    new XElement("Child4", 4),  
    new XText("mixed content"),  
    new XElement("Child5", 5)  
);  
xmlTree.RemoveNodes();  
Console.WriteLine(xmlTree);  
Dim xmltree As XElement = _   
    <Root>  
        <Child1>1</Child1>  
        <Child2>2</Child2>  
        <!--a comment-->  
        <Child3>3</Child3>  
        <Child4>4</Child4>mixed content<Child5>5</Child5>  
    </Root>  

xmltree.RemoveNodes()  
Console.WriteLine(xmltree)  

이 예제는 다음과 같은 출력을 생성합니다.

<Root />  

설명

특성을 포함하는 요소에서 이 메서드를 호출하는 경우 이 메서드는 특성을 제거하지 않습니다. 요소의 특성을 제거하려면 를 사용합니다 RemoveAttributes.

Remove 메서드에는 관련 기능이 있습니다. 컬렉션에 있는 모든 노드의 자식 노드를 제거합니다.

이 메서드는 및 이벤트를 발생 Changed 시킬 Changing 것입니다.

적용 대상

추가 정보