XText.NodeType 속성

정의

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

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

속성 값

XmlNodeType

노드 형식입니다. XText 개체의 경우 이 값은 Text입니다.

예제

다음 예제에서는 여러 유형의 노드가 포함된 XML 트리를 만듭니다. 그런 다음 트리를 반복하여 각 노드의 노드 형식을 출력합니다.

Child2 문자열 콘텐츠에서 암시적으로 변환된 노드를 포함합니다XText.

// 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", "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스의 컬렉션에서 작동하는 코드를 작성할 수 있습니다. 그러면 코드에서 컬렉션에 있는 각 노드의 노드 형식을 테스트할 수 있습니다.

적용 대상

추가 정보