XNode.DeepEquals(XNode, XNode) 메서드

정의

모든 하위 노드의 값을 포함하여 두 노드의 값을 비교합니다.

public:
 static bool DeepEquals(System::Xml::Linq::XNode ^ n1, System::Xml::Linq::XNode ^ n2);
public static bool DeepEquals(System.Xml.Linq.XNode n1, System.Xml.Linq.XNode n2);
public static bool DeepEquals(System.Xml.Linq.XNode? n1, System.Xml.Linq.XNode? n2);
static member DeepEquals : System.Xml.Linq.XNode * System.Xml.Linq.XNode -> bool
Public Shared Function DeepEquals (n1 As XNode, n2 As XNode) As Boolean

매개 변수

n1
XNode

비교할 첫 번째 XNode 입니다.

n2
XNode

비교할 두 번째 XNode 입니다.

반품

true 노드가 같으면 이고, 그렇지 않으면 false.

예제

다음 예제에서는 이 메서드를 사용하여 두 개의 XML 트리를 비교합니다.

XElement xmlTree1 = new XElement("Root",
    new XAttribute("Att1", 1),
    new XAttribute("Att2", 2),
    new XElement("Child1", 1),
    new XElement("Child2", "some content")
);
XElement xmlTree2 = new XElement("Root",
    new XAttribute("Att1", 1),
    new XAttribute("Att2", 2),
    new XElement("Child1", 1),
    new XElement("Child2", "some content")
);
Console.WriteLine(XNode.DeepEquals(xmlTree1, xmlTree2));
Dim xmlTree1 As XElement = _
        <Root Att1="1" Att2="2">
            <Child1>1</Child1>
            <Child2>some content</Child2>
        </Root>

Dim xmlTree2 As XElement = _
        <Root Att1="1" Att2="2">
            <Child1>1</Child1>
            <Child2>some content</Child2>
        </Root>

Console.WriteLine(XNode.DeepEquals(xmlTree1, xmlTree2))

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

True

설명

다음 조건은 두 노드가 같은지 여부를 결정합니다.

  • null 노드는 다른 null 노드와 같지만 비노드null 노드와 동일하지 않습니다.

  • 서로 다른 형식의 두 XNode 개체는 같지 않습니다.

  • XText 노드는 동일한 텍스트를 포함하는 경우 동일합니다.

  • XElement 노드는 동일한 태그 이름, 동일한 값을 가진 동일한 특성 집합이 있고(주석 및 처리 명령을 무시) 동일한 콘텐츠 노드의 길이 시퀀스가 동일한 두 개의 동일한 길이 시퀀스를 포함하는 경우 동일합니다.

  • 루트 노드가 같으면 두 XDocument 노드가 동일합니다.

  • XComment 노드는 동일한 주석 텍스트를 포함하는 경우 동일합니다.

  • XProcessingInstruction 노드는 동일한 대상 및 데이터가 있는 경우 동일합니다.

  • 이름, 공용 ID, 시스템 ID 및 내부 하위 집합이 같으면 두 XDocumentType 노드가 같습니다.

적용 대상

추가 정보