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.XmlNodeType
Public 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 子類別。 然後,您的程式碼可以測試集合中每個物件的節點類型。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應