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

節點類型。 對於 XAttribute 物件,此值為 Attribute

範例

下列範例會建立屬性,然後使用此屬性顯示節點類型。

XElement root = new XElement("Root",  
    new XAttribute("Att", "content")  
);  

XAttribute att = root.FirstAttribute;  
Console.WriteLine(att.NodeType);  
Dim root As XElement = <Root Att="content"/>  
Dim att As XAttribute = root.FirstAttribute  
Console.WriteLine(att.NodeType.ToString)  

這個範例會產生下列輸出:

Attribute  

備註

因為衍生自 XObject 的所有類別都包含 NodeType 屬性,所以您可以撰寫程式碼,以在 的具象子類別 XObject 集合上運作。 然後,您的程式碼可以測試集合中每個節點的節點類型。

適用於

另請參閱