XDocumentType.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

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

예제

다음 예제에서는 개체에 대 한 XDocumentType 노드 형식을 검색 하려면이 속성을 사용 합니다.

string internalSubset = @"<!ELEMENT Pubs (Book+)>  
<!ELEMENT Book (Title, Author)>  
<!ELEMENT Title (#PCDATA)>  
<!ELEMENT Author (#PCDATA)>";  

string target = "xml-stylesheet";  
string data = "href=\"mystyle.css\" title=\"Compact\" type=\"text/css\"";  

XDocument doc = new XDocument(  
    new XComment("This is a comment."),  
    new XProcessingInstruction(target, data),  
    new XDocumentType("Pubs", null, null, internalSubset),  
    new XElement("Pubs",   
        new XElement("Book",  
            new XElement("Title", "Artifacts of Roman Civilization"),  
            new XElement("Author", "Moreno, Jordao")  
        ),  
        new XElement("Book",  
            new XElement("Title", "Midieval Tools and Implements"),  
            new XElement("Author", "Gazit, Inbar")  
        )  
    ),  
    new XComment("This is another comment.")  
);  
doc.Declaration = new XDeclaration("1.0", "utf-8", "true");  

Console.WriteLine(doc.DocumentType.NodeType);  
Dim internalSubset = _  
    "<!ELEMENT Pubs (Book+)>" & Environment.NewLine & _  
    "<!ELEMENT Book (Title, Author)>" & Environment.NewLine & _  
    "<!ELEMENT Title (#PCDATA)>" & Environment.NewLine & _  
    "<!ELEMENT Author (#PCDATA)>"  

Dim doc As XDocument = _   
    <?xml version="1.0" encoding="utf-8" standalone="yes"?>  
    <!--This is a comment.-->  
    <?xml-stylesheet href='mystyle.css' title='Compact' type='text/css'?>  
    <Pubs>  
        <Book>  
            <Title>Artifacts of Roman Civilization</Title>  
            <Author>Moreno, Jordao</Author>  
        </Book>  
        <Book>  
            <Title>Midieval Tools and Implements</Title>  
            <Author>Gazit, Inbar</Author>  
        </Book>  
    </Pubs>  
    <!--This is another comment.-->  

doc.FirstNode.AddAfterSelf(new XDocumentType("Pubs", Nothing, Nothing, internalSubset))  

Console.WriteLine(doc.DocumentType.NodeType.ToString())  

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

DocumentType  

설명

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

적용 대상

추가 정보