XDocument.NodeType 属性  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取此节点的节点类型。
public:
 virtual property System::Xml::XmlNodeType NodeType { System::Xml::XmlNodeType get(); };public override System.Xml.XmlNodeType NodeType { get; }member this.NodeType : System.Xml.XmlNodeTypePublic Overrides ReadOnly Property NodeType As XmlNodeType属性值
节点类型。 对于 XDocument 对象,此值为 Document。
示例
以下示例演示了此属性的使用。
// Note that this property uses XmlNodeType, which is in the System.Xml namespace.  
XDocument xmlTree = new XDocument(  
    new XDeclaration("1.0", "utf-8", "yes"),  
    new XElement("Root", "content")  
);  
Console.WriteLine(xmlTree.NodeType);  
' Note that this property uses XmlNodeType, which is in the System.Xml namespace.  
Dim xmlTree As XDocument = _  
    <?xml version='1.0' encoding='utf-8' standalone='yes'?>  
        <Root>content</Root>  
Console.WriteLine("{0}", xmlTree.NodeType)  
该示例产生下面的输出:
Document  
注解
由于派生自 XObject 包含 NodeType 属性的所有类,因此可以编写对对象集合进行操作的代码,其中每个类的类型都是子类 XObject。 然后,代码可以测试集合中每个对象的节点类型。