XmlElement 类

定义

表示元素。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 类的新实例。Initializes a new instance of the XmlElement class.

属性

Attributes

获取包含此节点的属性列表的 XmlAttributeCollectionGets an XmlAttributeCollection containing the list of attributes for this node.

BaseURI

获取当前节点的基 URI。Gets the base URI of the current node.

(继承自 XmlNode)
ChildNodes

获取节点的所有子节点。Gets all the child nodes of the node.

(继承自 XmlNode)
FirstChild

获取节点的第一个子级。Gets the first child of the node.

(继承自 XmlNode)
HasAttributes

获取一个 boolean 值,该值指示当前节点是否有任何属性。Gets a boolean value indicating whether the current node has any attributes.

HasChildNodes

获取一个值,该值指示此节点是否有任何子节点。Gets a value indicating whether this node has any child nodes.

(继承自 XmlNode)
InnerText

获取或设置节点及其所有子级的串连值。Gets or sets the concatenated values of the node and all its children.

InnerXml

获取或设置仅表示此节点的子级的标记。Gets or sets the markup representing just the children of this node.

IsEmpty

获取或设置元素的标记格式。Gets or sets the tag format of the element.

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 current node.

Name

获取节点的限定名称。Gets the qualified name of the node.

NamespaceURI

获取该节点的命名空间 URI。Gets the namespace URI of this node.

NextSibling

获取紧接在该元素后面的 XmlNodeGets the XmlNode immediately following this element.

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.

ParentNode

获取该节点的父级(针对可以拥有父级的节点)。Gets the parent of this node (for nodes that can have parents).

Prefix

获取或设置该节点的命名空间前缀。Gets or sets the namespace prefix of this node.

PreviousSibling

获取紧接在该节点之前的节点。Gets the node immediately preceding this node.

(继承自 XmlLinkedNode)
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.

Value

获取或设置节点的值。Gets or sets the value of the node.

(继承自 XmlNode)

方法

AppendChild(XmlNode)

将指定的节点添加到该节点的子节点列表的末尾。Adds the specified node to the end of the list of child nodes, of this node.

(继承自 XmlNode)
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)
GetAttribute(String)

返回具有指定名称的属性的值。Returns the value for the attribute with the specified name.

GetAttribute(String, String)

返回具有指定本地名称和命名空间 URI 的特性的值。Returns the value for the attribute with the specified local name and namespace URI.

GetAttributeNode(String)

返回具有指定名称的 XmlAttributeReturns the XmlAttribute with the specified name.

GetAttributeNode(String, String)

返回具有指定本地名称和命名空间 URI 的 XmlAttributeReturns the XmlAttribute with the specified local name and namespace URI.

GetElementsByTagName(String)

返回一个 XmlNodeList,它包含与指定 Name 匹配的所有子代元素的列表。Returns an XmlNodeList containing a list of all descendant elements that match the specified Name.

GetElementsByTagName(String, String)

返回一个 XmlNodeList,它包含与指定 LocalNameNamespaceURI 匹配的所有子代元素的列表。Returns an XmlNodeList containing a list of all descendant elements that match the specified LocalName and NamespaceURI.

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)
HasAttribute(String)

确定当前节点是否具有带有指定名称的属性。Determines whether the current node has an attribute with the specified name.

HasAttribute(String, String)

确定当前节点是否具有带有指定本地名称和命名空间 URI 的特性。Determines whether the current node has an attribute with the specified local name and namespace URI.

InsertAfter(XmlNode, XmlNode)

将指定的节点紧接着插入指定的引用节点之后。Inserts the specified node immediately after the specified reference node.

(继承自 XmlNode)
InsertBefore(XmlNode, XmlNode)

将指定的节点紧接着插入指定的引用节点之前。Inserts the specified node immediately before the specified reference node.

(继承自 XmlNode)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Normalize()

将此 XmlNode 下子树完全深度中的所有 XmlText 节点都转换成“正常”形式,在这种形式中只有标记(即标记、注释、处理指令、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.

(继承自 XmlNode)
RemoveAll()

删除当前节点的所有指定特性和子级。Removes all specified attributes and children of the current node. 不删除默认属性。Default attributes are not removed.

RemoveAllAttributes()

从元素中删除所有指定的属性。Removes all specified attributes from the element. 不删除默认属性。Default attributes are not removed.

RemoveAttribute(String)

按名称删除特性。Removes an attribute by name.

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)

从元素中删除具有指定索引的特性节点。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)

移除由本地名称和命名空间 URI 指定的 XmlAttributeRemoves the XmlAttribute specified by the local name and namespace URI. (如果删除的特性具有默认值时,则将立即替换它)。(If the removed attribute has a default value, it is immediately replaced).

RemoveAttributeNode(XmlAttribute)

删除指定的 XmlAttributeRemoves the specified XmlAttribute.

RemoveChild(XmlNode)

移除指定的子节点。Removes specified child node.

(继承自 XmlNode)
ReplaceChild(XmlNode, XmlNode)

oldChild 节点替换子节点 newChildReplaces the child node oldChild with newChild node.

(继承自 XmlNode)
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. XPath 表达式中的任何前缀都使用提供的 XmlNamespaceManager 进行解析。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. XPath 表达式中的任何前缀都使用提供的 XmlNamespaceManager 进行解析。Any prefixes found in the XPath expression are resolved using the supplied XmlNamespaceManager.

(继承自 XmlNode)
SetAttribute(String, String)

设置具有指定名称的特性的值。Sets the value of the attribute with the specified name.

SetAttribute(String, String, String)

设置具有指定本地名称和命名空间 URI 的特性的值。Sets the value of the attribute with the specified local name and namespace URI.

SetAttributeNode(String, String)

添加指定的 XmlAttributeAdds the specified XmlAttribute.

SetAttributeNode(XmlAttribute)

添加指定的 XmlAttributeAdds the specified XmlAttribute.

Supports(String, String)

测试 DOM 实现是否实现特定的功能。Tests if the DOM implementation implements a specific feature.

(继承自 XmlNode)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
WriteContentTo(XmlWriter)

将该节点的所有子项保存到指定的 XmlWriter 中。Saves all the children of the node to the specified XmlWriter.

WriteTo(XmlWriter)

将当前节点保存到指定的 XmlWriterSaves the current 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)

适用于

另请参阅