XObject.NodeType 속성

정의

XObject에 대한 노드 형식을 가져옵니다.

public:
 abstract property System::Xml::XmlNodeType NodeType { System::Xml::XmlNodeType get(); };
public abstract System.Xml.XmlNodeType NodeType { get; }
member this.NodeType : System.Xml.XmlNodeType
Public MustOverride ReadOnly Property NodeType As XmlNodeType

속성 값

XmlNodeType

XObject에 대한 노드 형식입니다.

예제

다음 예제에서는 이 메서드를 사용하여 다양한 노드에 대한 노드 유형을 검색합니다.

// Note that XNode uses XmlNodeType, which is in the System.Xml namespace.  
XDocument xmlTree = new XDocument(  
    new XComment("a comment"),  
    new XProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"hello.xsl\""),  
    new XElement("Root",  
        new XAttribute("Att", "attContent"),  
        new XElement("Child1",  
            new XCData("CDATA content")  
        ),  
        new XElement("Child2",  
            new XText("Text content")  
        )  
    )  
);  

foreach (XNode node in xmlTree.DescendantNodes())  
{  
    Console.WriteLine(node.NodeType);  
    if (node.NodeType == XmlNodeType.Element)  
    {  
        foreach (XAttribute att in ((XElement)node).Attributes())  
            Console.WriteLine(att.NodeType);  
    }  
}  
' Note that XNode uses XmlNodeType, which is in the System.Xml  namespace.  
Dim xmlTree As XDocument = _   
    <?xml version="1.0"?>  
    <!--a comment-->  
    <?xml-stylesheet type="text/xsl" href="hello.xsl"?>  
    <Root Att="attContent">  
        <Child1><![CDATA[CDATA content]

설명

파생되는 XObject 모든 클래스는 속성을 포함 NodeType 하므로 구체적인 서브클래 XObject스의 컬렉션에서 작동하는 코드를 작성할 수 있습니다. 그러면 코드에서 컬렉션에 있는 각 노드의 노드 형식을 테스트할 수 있습니다.

적용 대상

추가 정보