XmlElement XmlElement XmlElement XmlElement Class

定義

表示項目。Represents an element.

public ref class XmlElement : System::Xml::XmlLinkedNode
public class XmlElement : System.Xml.XmlLinkedNode
type XmlElement = class
    inherit XmlLinkedNode
Public Class XmlElement
Inherits XmlLinkedNode
繼承

備註

元素可以是其中一個最常見的節點在 W3C 文件物件模型 (DOM)。Elements are one of the most common nodes in the W3C Document Object Model (DOM). 項目可以有與其相關聯的屬性。Elements can have attributes associated with them. XmlElement類別有許多方法來存取屬性 (GetAttributeSetAttributeRemoveAttributeGetAttributeNode等等)。The XmlElement class has many methods for accessing attributes (GetAttribute, SetAttribute, RemoveAttribute, GetAttributeNode, and so on). 您也可以使用Attributes屬性會傳回XmlAttributeCollection讓您存取集合中的依名稱或索引的屬性。You can also use the Attributes property which returns an XmlAttributeCollection enabling you to access attributes by name or index from the collection.

建構函式

XmlElement(String, String, String, XmlDocument) XmlElement(String, String, String, XmlDocument) XmlElement(String, String, String, XmlDocument) XmlElement(String, String, String, XmlDocument)

初始化 XmlElement 類別的新執行個體。Initializes a new instance of the XmlElement class.

屬性

Attributes Attributes Attributes Attributes

取得包含這個節點之屬性清單的 XmlAttributeCollectionGets an XmlAttributeCollection containing the list of attributes for this node.

BaseURI BaseURI BaseURI BaseURI

取得目前節點的基底 (Base) URI。Gets the base URI of the current node.

(Inherited from XmlNode)
ChildNodes ChildNodes ChildNodes ChildNodes

取得節點的所有子節點。Gets all the child nodes of the node.

(Inherited from XmlNode)
FirstChild FirstChild FirstChild FirstChild

取得節點的第一個子節點。Gets the first child of the node.

(Inherited from XmlNode)
HasAttributes HasAttributes HasAttributes HasAttributes

取得 boolean 值,表示目前節點是否有屬性。Gets a boolean value indicating whether the current node has any attributes.

HasChildNodes HasChildNodes HasChildNodes HasChildNodes

取得值,指出這個節點是否有子節點。Gets a value indicating whether this node has any child nodes.

(Inherited from XmlNode)
InnerText InnerText InnerText InnerText

取得或設定節點的串連值和其所有的子節點。Gets or sets the concatenated values of the node and all its children.

InnerXml InnerXml InnerXml InnerXml

取得或設定標記,表示這個節點的子節點。Gets or sets the markup representing just the children of this node.

IsEmpty IsEmpty IsEmpty IsEmpty

取得或設定項目的標記格式。Gets or sets the tag format of the element.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

取得值,表示節點是否為唯讀。Gets a value indicating whether the node is read-only.

(Inherited from XmlNode)
Item[String, String] Item[String, String] Item[String, String] Item[String, String]

取得具有指定的 LocalNameNamespaceURI 的第一個子項目。Gets the first child element with the specified LocalName and NamespaceURI.

(Inherited from XmlNode)
Item[String] Item[String] Item[String] Item[String]

取得具有指定的 Name 的第一個子項目。Gets the first child element with the specified Name.

(Inherited from XmlNode)
LastChild LastChild LastChild LastChild

取得節點的最後一個子節點。Gets the last child of the node.

(Inherited from XmlNode)
LocalName LocalName LocalName LocalName

取得目前節點的區域名稱。Gets the local name of the current node.

Name Name Name Name

取得節點的限定名稱。Gets the qualified name of the node.

NamespaceURI NamespaceURI NamespaceURI NamespaceURI

取得這個節點的命名空間 URI。Gets the namespace URI of this node.

NextSibling NextSibling NextSibling NextSibling

取得緊接在這個項目之後的 XmlNodeGets the XmlNode immediately following this element.

NodeType NodeType NodeType NodeType

取得目前節點的類型。Gets the type of the current node.

OuterXml OuterXml OuterXml OuterXml

取得包含這個節點和其所有子節點的標記。Gets the markup containing this node and all its child nodes.

(Inherited from XmlNode)
OwnerDocument OwnerDocument OwnerDocument OwnerDocument

取得這個節點所屬的 XmlDocumentGets the XmlDocument to which this node belongs.

ParentNode ParentNode ParentNode ParentNode

取得這個節點的父代 (對於具有父代的節點而言)。Gets the parent of this node (for nodes that can have parents).

Prefix Prefix Prefix Prefix

取得或設定這個節點的命名空間前置詞。Gets or sets the namespace prefix of this node.

PreviousSibling PreviousSibling PreviousSibling PreviousSibling

取得這個節點的前置節點。Gets the node immediately preceding this node.

(Inherited from XmlLinkedNode)
PreviousText PreviousText PreviousText PreviousText

取得這個節點的前置文字節點。Gets the text node that immediately precedes this node.

(Inherited from XmlNode)
SchemaInfo SchemaInfo SchemaInfo SchemaInfo

取得後結構描述驗證資訊集,在結構描述驗證之後已將其指派給這個節點。Gets the post schema validation infoset that has been assigned to this node as a result of schema validation.

Value Value Value Value

取得或設定節點的值。Gets or sets the value of the node.

(Inherited from XmlNode)

方法

AppendChild(XmlNode) AppendChild(XmlNode) AppendChild(XmlNode) AppendChild(XmlNode)

將指定的節點加入這個節點之子節點清單的結尾。Adds the specified node to the end of the list of child nodes, of this node.

(Inherited from XmlNode)
Clone() Clone() Clone() Clone()

建立這個節點的複本。Creates a duplicate of this node.

(Inherited from XmlNode)
CloneNode(Boolean) CloneNode(Boolean) CloneNode(Boolean) CloneNode(Boolean)

建立這個節點的複本。Creates a duplicate of this node.

CreateNavigator() CreateNavigator() CreateNavigator() CreateNavigator()

建立 XPathNavigator 以瀏覽這個物件。Creates an XPathNavigator for navigating this object.

(Inherited from XmlNode)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetAttribute(String) GetAttribute(String) GetAttribute(String) GetAttribute(String)

傳回具有指定名稱之屬性的值。Returns the value for the attribute with the specified name.

GetAttribute(String, String) GetAttribute(String, String) GetAttribute(String, String) GetAttribute(String, String)

傳回具有指定區域名稱和命名空間 URI 之屬性的值。Returns the value for the attribute with the specified local name and namespace URI.

GetAttributeNode(String) GetAttributeNode(String) GetAttributeNode(String) GetAttributeNode(String)

傳回具有指定名稱的 XmlAttributeReturns the XmlAttribute with the specified name.

GetAttributeNode(String, String) GetAttributeNode(String, String) GetAttributeNode(String, String) GetAttributeNode(String, String)

傳回具有指定區域名稱和命名空間 URI 的 XmlAttributeReturns the XmlAttribute with the specified local name and namespace URI.

GetElementsByTagName(String) GetElementsByTagName(String) GetElementsByTagName(String) GetElementsByTagName(String)

傳回 XmlNodeList,其中包含符合指定 Name 之所有子代 (Descendant) 項目的清單。Returns an XmlNodeList containing a list of all descendant elements that match the specified Name.

GetElementsByTagName(String, String) GetElementsByTagName(String, String) GetElementsByTagName(String, String) GetElementsByTagName(String, String)

傳回 XmlNodeList,其中包含符合指定之 LocalNameNamespaceURI 的所有子代元素的清單。Returns an XmlNodeList containing a list of all descendant elements that match the specified LocalName and NamespaceURI.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

取得逐一查看目前節點中子節點的列舉程式。Gets an enumerator that iterates through the child nodes in the current node.

(Inherited from XmlNode)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetNamespaceOfPrefix(String) GetNamespaceOfPrefix(String) GetNamespaceOfPrefix(String) GetNamespaceOfPrefix(String)

查閱目前節點範圍內最接近指定前置詞的 xmlns 宣告,並傳回宣告中的命名空間 URI。Looks up the closest xmlns declaration for the given prefix that is in scope for the current node and returns the namespace URI in the declaration.

(Inherited from XmlNode)
GetPrefixOfNamespace(String) GetPrefixOfNamespace(String) GetPrefixOfNamespace(String) GetPrefixOfNamespace(String)

查閱目前節點範圍內最接近指定命名空間 URI 的 xmlns 宣告,並傳回宣告中所定義的前置詞。Looks up the closest xmlns declaration for the given namespace URI that is in scope for the current node and returns the prefix defined in that declaration.

(Inherited from XmlNode)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
HasAttribute(String) HasAttribute(String) HasAttribute(String) HasAttribute(String)

判斷目前的節點是否具有指定名稱的屬性。Determines whether the current node has an attribute with the specified name.

HasAttribute(String, String) HasAttribute(String, String) HasAttribute(String, String) HasAttribute(String, String)

判斷目前的節點是否有具有指定區域名稱和命名空間 URI 的屬性。Determines whether the current node has an attribute with the specified local name and namespace URI.

InsertAfter(XmlNode, XmlNode) InsertAfter(XmlNode, XmlNode) InsertAfter(XmlNode, XmlNode) InsertAfter(XmlNode, XmlNode)

在指定的參考節點之後,插入指定的節點。Inserts the specified node immediately after the specified reference node.

(Inherited from XmlNode)
InsertBefore(XmlNode, XmlNode) InsertBefore(XmlNode, XmlNode) InsertBefore(XmlNode, XmlNode) InsertBefore(XmlNode, XmlNode)

在指定的參考節點之前,插入指定的節點。Inserts the specified node immediately before the specified reference node.

(Inherited from XmlNode)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(Inherited from Object)
Normalize() Normalize() Normalize() Normalize()

使這個 XmlNode 之下子樹狀結構的整個深度中所有 XmlText 節點成為「一般」形式,其中只用標記 (Markup) (亦即標記 (Tag)、註解、處理指示、CDATA 區段與實體參考) 來分隔 XmlText 節點,也就是說,沒有相鄰的 XmlText 節點。Puts all XmlText nodes in the full depth of the sub-tree underneath this XmlNode into a "normal" form where only markup (that is, tags, comments, processing instructions, CDATA sections, and entity references) separates XmlText nodes, that is, there are no adjacent XmlText nodes.

(Inherited from XmlNode)
PrependChild(XmlNode) PrependChild(XmlNode) PrependChild(XmlNode) PrependChild(XmlNode)

將指定的節點加入這個節點之子節點清單的開頭。Adds the specified node to the beginning of the list of child nodes for this node.

(Inherited from XmlNode)
RemoveAll() RemoveAll() RemoveAll() RemoveAll()

移除目前節點所有指定的屬性和子系。Removes all specified attributes and children of the current node. 預設屬性不會移除。Default attributes are not removed.

RemoveAllAttributes() RemoveAllAttributes() RemoveAllAttributes() RemoveAllAttributes()

移除項目中所有指定的屬性。Removes all specified attributes from the element. 預設屬性不會移除。Default attributes are not removed.

RemoveAttribute(String) RemoveAttribute(String) RemoveAttribute(String) RemoveAttribute(String)

依照名稱移除屬性。Removes an attribute by name.

RemoveAttribute(String, String) RemoveAttribute(String, String) RemoveAttribute(String, String) RemoveAttribute(String, String)

移除具有指定區域名稱和命名空間 URI 的屬性 Removes an attribute with the specified local name and namespace URI. (如果移除的屬性具有預設值,會立即被取代)。(If the removed attribute has a default value, it is immediately replaced).

RemoveAttributeAt(Int32) RemoveAttributeAt(Int32) RemoveAttributeAt(Int32) RemoveAttributeAt(Int32)

移除項目中具有指定索引的屬性節點 Removes the attribute node with the specified index from the element. (如果移除的屬性具有預設值,會立即被取代)。(If the removed attribute has a default value, it is immediately replaced).

RemoveAttributeNode(String, String) RemoveAttributeNode(String, String) RemoveAttributeNode(String, String) RemoveAttributeNode(String, String)

移除區域名稱和命名空間 URI 指定的 XmlAttribute Removes the XmlAttribute specified by the local name and namespace URI. (如果移除的屬性具有預設值,會立即被取代)。(If the removed attribute has a default value, it is immediately replaced).

RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute) RemoveAttributeNode(XmlAttribute)

移除指定的 XmlAttributeRemoves the specified XmlAttribute.

RemoveChild(XmlNode) RemoveChild(XmlNode) RemoveChild(XmlNode) RemoveChild(XmlNode)

移除指定的子節點。Removes specified child node.

(Inherited from XmlNode)
ReplaceChild(XmlNode, XmlNode) ReplaceChild(XmlNode, XmlNode) ReplaceChild(XmlNode, XmlNode) ReplaceChild(XmlNode, XmlNode)

將子節點 oldChildnewChild 節點取代。Replaces the child node oldChild with newChild node.

(Inherited from XmlNode)
SelectNodes(String) SelectNodes(String) SelectNodes(String) SelectNodes(String)

選取符合 XPath 運算式的節點清單。Selects a list of nodes matching the XPath expression.

(Inherited from XmlNode)
SelectNodes(String, XmlNamespaceManager) SelectNodes(String, XmlNamespaceManager) SelectNodes(String, XmlNamespaceManager) SelectNodes(String, XmlNamespaceManager)

選取符合 XPath 運算式的節點清單。Selects a list of nodes matching the XPath expression. 使用提供的 XmlNamespaceManager 解析 XPath 運算式中找到的任何前置詞。Any prefixes found in the XPath expression are resolved using the supplied XmlNamespaceManager.

(Inherited from XmlNode)
SelectSingleNode(String) SelectSingleNode(String) SelectSingleNode(String) SelectSingleNode(String)

選取符合 XPath 運算式的第一個 XmlNodeSelects the first XmlNode that matches the XPath expression.

(Inherited from XmlNode)
SelectSingleNode(String, XmlNamespaceManager) SelectSingleNode(String, XmlNamespaceManager) SelectSingleNode(String, XmlNamespaceManager) SelectSingleNode(String, XmlNamespaceManager)

選取符合 XPath 運算式的第一個 XmlNodeSelects the first XmlNode that matches the XPath expression. 使用提供的 XmlNamespaceManager 解析 XPath 運算式中找到的任何前置詞。Any prefixes found in the XPath expression are resolved using the supplied XmlNamespaceManager.

(Inherited from XmlNode)
SetAttribute(String, String) SetAttribute(String, String) SetAttribute(String, String) SetAttribute(String, String)

設定具有指定名稱之屬性的值。Sets the value of the attribute with the specified name.

SetAttribute(String, String, String) SetAttribute(String, String, String) SetAttribute(String, String, String) SetAttribute(String, String, String)

設定具有指定區域名稱和命名空間 URI 之屬性的值。Sets the value of the attribute with the specified local name and namespace URI.

SetAttributeNode(String, String) SetAttributeNode(String, String) SetAttributeNode(String, String) SetAttributeNode(String, String)

加入指定的 XmlAttributeAdds the specified XmlAttribute.

SetAttributeNode(XmlAttribute) SetAttributeNode(XmlAttribute) SetAttributeNode(XmlAttribute) SetAttributeNode(XmlAttribute)

加入指定的 XmlAttributeAdds the specified XmlAttribute.

Supports(String, String) Supports(String, String) Supports(String, String) Supports(String, String)

測試 DOM 實作 (Implementation) 是否實作特定功能。Tests if the DOM implementation implements a specific feature.

(Inherited from XmlNode)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)
WriteContentTo(XmlWriter) WriteContentTo(XmlWriter) WriteContentTo(XmlWriter) WriteContentTo(XmlWriter)

將此節點的所有子系儲存到指定的 XmlWriterSaves all the children of the node to the specified XmlWriter.

WriteTo(XmlWriter) WriteTo(XmlWriter) WriteTo(XmlWriter) WriteTo(XmlWriter)

將目前的節點儲存至指定的 XmlWriterSaves the current node to the specified XmlWriter.

明確介面實作

ICloneable.Clone() ICloneable.Clone() ICloneable.Clone() ICloneable.Clone()

如需這個成員的說明,請參閱 Clone()For a description of this member, see Clone().

(Inherited from XmlNode)
IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

如需這個成員的說明,請參閱 GetEnumerator()For a description of this member, see GetEnumerator().

(Inherited from XmlNode)

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

篩選的項目IEnumerable根據指定的型別。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

CreateNavigator(XmlNode) CreateNavigator(XmlNode) CreateNavigator(XmlNode) CreateNavigator(XmlNode)
SelectNodes(XmlNode, String) SelectNodes(XmlNode, String) SelectNodes(XmlNode, String) SelectNodes(XmlNode, String)
SelectNodes(XmlNode, String, XmlNamespaceManager) SelectNodes(XmlNode, String, XmlNamespaceManager) SelectNodes(XmlNode, String, XmlNamespaceManager) SelectNodes(XmlNode, String, XmlNamespaceManager)
SelectSingleNode(XmlNode, String) SelectSingleNode(XmlNode, String) SelectSingleNode(XmlNode, String) SelectSingleNode(XmlNode, String)
SelectSingleNode(XmlNode, String, XmlNamespaceManager) SelectSingleNode(XmlNode, String, XmlNamespaceManager) SelectSingleNode(XmlNode, String, XmlNamespaceManager) SelectSingleNode(XmlNode, String, XmlNamespaceManager)
ToXPathNavigable(XmlNode) ToXPathNavigable(XmlNode) ToXPathNavigable(XmlNode) ToXPathNavigable(XmlNode)

適用於

另請參閱