XmlAttribute 類別

定義

表示屬性 (Attribute)。Represents an attribute. 屬性的有效和預設值是在文件類型定義 (DTD) 或結構描述中定義。Valid and default values for the attribute are defined in a document type definition (DTD) or schema.

public ref class XmlAttribute : System::Xml::XmlNode
public class XmlAttribute : System.Xml.XmlNode
type XmlAttribute = class
    inherit XmlNode
Public Class XmlAttribute
Inherits XmlNode
繼承
XmlAttribute

備註

屬性可以與元素相關聯。Attributes can be associated with an element. 使用屬性,即可取得屬性XmlElement所屬的。 OwnerElementUse the OwnerElement property to get the XmlElement to which the attribute belongs.

類別有數個方法,可讓您存取屬性節點(XmlElement.GetAttributeXmlElement.SetAttributeXmlElement.RemoveAttribute等等)。 XmlElementThe XmlElement class has several methods which allow you to access attribute nodes (XmlElement.GetAttribute, XmlElement.SetAttribute, XmlElement.RemoveAttribute, and so on). 此外,您可以呼叫XmlElement.Attributes屬性,它XmlAttributeCollection會傳回,讓您從集合中依名稱或索引來存取屬性。Additionally, you can call the XmlElement.Attributes property, which returns an XmlAttributeCollection enabling you to access attributes by name or index from the collection.

建構函式

XmlAttribute(String, String, String, XmlDocument)

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

屬性

Attributes

取得包含這個節點屬性 (Attribute) 的 XmlAttributeCollectionGets an XmlAttributeCollection containing the attributes of this node.

(繼承來源 XmlNode)
BaseURI

取得節點的基底統一資源識別元 (URI)。Gets the base Uniform Resource Identifier (URI) of the node.

ChildNodes

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

(繼承來源 XmlNode)
FirstChild

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

(繼承來源 XmlNode)
HasChildNodes

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

(繼承來源 XmlNode)
InnerText

設定節點的串連值和其所有的子節點。Sets the concatenated values of the node and all its children.

InnerXml

設定屬性值。Sets the value of the attribute.

IsReadOnly

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

(繼承來源 XmlNode)
Item[String, String]

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

(繼承來源 XmlNode)
Item[String]

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

(繼承來源 XmlNode)
LastChild

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

(繼承來源 XmlNode)
LocalName

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

Name

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

NamespaceURI

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

NextSibling

取得這個節點的後置節點。Gets the node immediately following this node.

(繼承來源 XmlNode)
NodeType

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

OuterXml

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

(繼承來源 XmlNode)
OwnerDocument

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

OwnerElement

取得屬性所屬的 XmlElementGets the XmlElement to which the attribute belongs.

ParentNode

取得這個節點的父代 (Parent)。Gets the parent of this node. 對於 XmlAttribute 節點,這個屬性永遠傳回 nullFor XmlAttribute nodes, this property always returns null.

Prefix

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

PreviousSibling

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

(繼承來源 XmlNode)
PreviousText

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

(繼承來源 XmlNode)
SchemaInfo

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

Specified

取得值,表示是否明確設定屬性值。Gets a value indicating whether the attribute value was explicitly set.

Value

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

方法

AppendChild(XmlNode)

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

Clone()

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

(繼承來源 XmlNode)
CloneNode(Boolean)

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

CreateNavigator()

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

(繼承來源 XmlNode)
Equals(Object)

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

(繼承來源 Object)
GetEnumerator()

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

(繼承來源 XmlNode)
GetHashCode()

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

(繼承來源 Object)
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.

(繼承來源 XmlNode)
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.

(繼承來源 XmlNode)
GetType()

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

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

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

InsertBefore(XmlNode, XmlNode)

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

MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
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.

(繼承來源 XmlNode)
PrependChild(XmlNode)

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

RemoveAll()

移除目前節點的所有子節點和/或屬性。Removes all the child nodes and/or attributes of the current node.

(繼承來源 XmlNode)
RemoveChild(XmlNode)

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

ReplaceChild(XmlNode, XmlNode)

用指定的新子節點取代指定的子節點。Replaces the child node specified with the new child node specified.

SelectNodes(String)

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

(繼承來源 XmlNode)
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.

(繼承來源 XmlNode)
SelectSingleNode(String)

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

(繼承來源 XmlNode)
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.

(繼承來源 XmlNode)
Supports(String, String)

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

(繼承來源 XmlNode)
ToString()

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

(繼承來源 Object)
WriteContentTo(XmlWriter)

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

WriteTo(XmlWriter)

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

明確介面實作

ICloneable.Clone()

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

(繼承來源 XmlNode)
IEnumerable.GetEnumerator()

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

(繼承來源 XmlNode)

擴充方法

Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable)

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

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

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

適用於

另請參閱