XmlNode 類別

定義

代表 XML 文件中的單一節點。

public ref class XmlNode abstract : System::Collections::IEnumerable
public ref class XmlNode abstract : ICloneable, System::Collections::IEnumerable, System::Xml::XPath::IXPathNavigable
public abstract class XmlNode : System.Collections.IEnumerable
public abstract class XmlNode : ICloneable, System.Collections.IEnumerable, System.Xml.XPath.IXPathNavigable
type XmlNode = class
    interface IEnumerable
type XmlNode = class
    interface IEnumerable
    interface ICloneable
    interface IXPathNavigable
type XmlNode = class
    interface ICloneable
    interface IEnumerable
    interface IXPathNavigable
Public MustInherit Class XmlNode
Implements IEnumerable
Public MustInherit Class XmlNode
Implements ICloneable, IEnumerable, IXPathNavigable
繼承
XmlNode
衍生
實作

備註

此類別實作 W3C 文件物件模型(DOM)第一級核心與核心 DOM 第二級。 DOM 是 XML 檔的記憶體內部樹狀結構表示法。 XmlNode 是 DOM .NET實作中的基底類別。 它支援 XPath 選區,並提供編輯功能。 這個 XmlDocument 類別擴展 XmlNode 並表示一個 XML 文件。 你可以用來 XmlDocument 載入和儲存 XML 資料。 它也包含節點建立的方法。 更多資訊請參閱 XML 文件物件模型(DOM)。

Important

因使用 XmlNode 類別而引發的例外狀況,例如 類別 XmlException 可能包含不應在不受信任的案例中公開的敏感性資訊。 應正確處理例外狀況,如此一來,此敏感性資訊就不會在不受信任的案例中公開。

屬性

名稱 Description
Attributes

會得到包含 XmlAttributeCollection 該節點屬性的 。

BaseURI

取得目前節點的基礎 URI。

ChildNodes

取得該節點的所有子節點。

FirstChild

取得節點的第一個子節點。

HasChildNodes

會得到一個值,表示該節點是否有子節點。

InnerText

取得或設定該節點及其所有子節點的串接值。

InnerXml

取得或設定標記,僅代表該節點的子節點。

IsReadOnly

會得到一個值,表示該節點是否為唯讀。

Item[String, String]

取得第一個子元素,且指定為 LocalNameNamespaceURI

Item[String]

取得第一個子元素,指定為 Name

LastChild

取得節點的最後一個子節點。

LocalName

當在導出類別中覆寫時,會取得節點的本地名稱。

Name

當在派生類別中覆寫時,會取得該節點的限定名稱。

NamespaceURI

取得該節點的命名空間 URI。

NextSibling

取得緊接該節點的節點。

NodeType

當在衍生類別中覆寫時,會取得目前節點的型別。

OuterXml

取得包含此節點及其所有子節點的標記。

OwnerDocument

取得該節點所屬的 。XmlDocument

ParentNode

取得該節點的父節點(對於可以有父節點的節點)。

Prefix

取得或設定此節點的命名空間前綴。

PreviousSibling

取得緊鄰該節點的節點。

PreviousText

取得緊鄰此節點的文字節點。

SchemaInfo

取得因結構驗證而指派給該節點的後 schema 驗證資訊集。

Value

取得或設定節點的值。

方法

名稱 Description
AppendChild(XmlNode)

將指定的節點加入該節點子節點清單的末尾。

Clone()

會建立這個節點的複製品。

CloneNode(Boolean)

當在衍生類別中被覆寫時,會建立該節點的複製品。

CreateNavigator()

建立 XPathNavigator 一個用於導航此物件的

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEnumerator()

會得到一個列舉器,會遍歷目前節點的子節點。

GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetNamespaceOfPrefix(String)

查找目前節點範圍內最接近該前綴的 xmlns 宣告,並回傳宣告中的命名空間 URI。

GetPrefixOfNamespace(String)

查找目前節點範圍內的命名空間 URI 中最接近的 xmlns 宣告,並回傳該宣告中定義的前綴。

GetType()

取得目前實例的 Type

(繼承來源 Object)
InsertAfter(XmlNode, XmlNode)

在指定的參考節點之後立即插入指定的節點。

InsertBefore(XmlNode, XmlNode)

在指定的參考節點之前插入指定的節點。

MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
Normalize()

將所有位於此 XmlNode 下方子樹深度的 XmlText 節點置於「正常」形式,僅有標記(即標籤、註解、處理指令、CDATA 區段及實體參考)分隔 XmlText 節點,也就是說,沒有相鄰的 XmlText 節點。

PrependChild(XmlNode)

將指定節點加入該節點子節點清單的開頭。

RemoveAll()

移除目前節點的所有子節點和/或屬性。

RemoveChild(XmlNode)

移除指定的子節點。

ReplaceChild(XmlNode, XmlNode)

將子節點 oldChild 替換為 newChild 節點。

SelectNodes(String, XmlNamespaceManager)

選取與 XPath 表達式相符的節點清單。 XPath 表達式中發現的任何前綴皆可透過提供的 XmlNamespaceManager解析 。

SelectNodes(String)

選取與 XPath 表達式相符的節點清單。

SelectSingleNode(String, XmlNamespaceManager)

選擇第一個 XmlNode 與 XPath 表達式相符的字母。 XPath 表達式中發現的任何前綴皆可透過提供的 XmlNamespaceManager解析 。

SelectSingleNode(String)

選擇第一個 XmlNode 與 XPath 表達式相符的字母。

Supports(String, String)

測試 DOM 實作是否實作了特定功能。

ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)
WriteContentTo(XmlWriter)

當在導出類別中覆寫時,將該節點的所有子節點儲存為指定的 XmlWriter

WriteTo(XmlWriter)

當在導出類別中覆寫時,將當前節點儲存為指定的 XmlWriter

明確介面實作

名稱 Description
ICloneable.Clone()

關於此成員的描述,請參見 Clone()

IEnumerable.GetEnumerator()

關於此成員的描述,請參見 GetEnumerator()

擴充方法

名稱 Description
AsParallel(IEnumerable)

啟用查詢的平行處理。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

CreateNavigator(XmlNode)

建立一個 XPath 導航器來導航指定節點。

OfType<TResult>(IEnumerable)

根據指定的型別篩選 IEnumerable 的專案。

SelectNodes(XmlNode, String, XmlNamespaceManager)

選取與指定 XPath 表達式相符的節點清單。 XPath 表達式中發現的任何前綴,皆可透過提供的命名空間管理器解析。

SelectNodes(XmlNode, String)

選取與指定 XPath 表達式相符的節點清單。

SelectSingleNode(XmlNode, String, XmlNamespaceManager)

選擇第一個與 XPath 表達式相符的節點。 XPath 表達式中發現的任何前綴,皆可透過提供的命名空間管理器解析。

SelectSingleNode(XmlNode, String)

選擇第一個與 XPath 表達式相符的節點。

ToXPathNavigable(XmlNode)

建立 IXPathNavigable 一個用來產生導航員的實例。

適用於

另請參閱