XNode 类
定义
表示 XML 树中节点的抽象概念(元素、注释、文档类型、处理指令或文本节点)。Represents the abstract concept of a node (element, comment, document type, processing instruction, or text node) in the XML tree.
public ref class XNode abstract : System::Xml::Linq::XObject
public abstract class XNode : System.Xml.Linq.XObject
type XNode = class
inherit XObject
Public MustInherit Class XNode
Inherits XObject
- 继承
- 派生
注解
XNode 是以下类型的抽象公共基类:XNode is an abstract common base class for the following types:
XContainer 是以下类型的抽象公共基类:XContainer is an abstract common base class for the following types:
派生自的类的对象 XContainer 可包含子节点。Objects of classes that derive from XContainer can contain child nodes.
备注
XAttribute不是 XNode 。An XAttribute is not an XNode. 特性作为元素的名称/值对列表进行维护。Attributes are maintained as a list of name/value pairs on an element.
如果您要编写一个复杂的 XML 应用程序(例如,将内容存储为 XML 的 XML 编辑器或字处理器),则通常会在节点级别上工作。If you are writing a complex XML application, such as an XML editor or a word processor that stores content as XML, you will often work at the node level. 在节点级别工作时的典型活动包括添加节点、删除节点、转换节点以及循环访问返回节点集合的轴。Typical activities when working at the node level include adding nodes, deleting nodes, transforming nodes, and iterating through axes that return collections of nodes.
属性
| BaseUri |
获取此 XObject 的基 URI。Gets the base URI for this XObject. (继承自 XObject) |
| Document |
获取此 XDocument 的 XObject。Gets the XDocument for this XObject. (继承自 XObject) |
| DocumentOrderComparer |
获取可以比较两个节点相对位置的比较器。Gets a comparer that can compare the relative position of two nodes. |
| EqualityComparer |
获取可以比较两个节点值是否相等的比较器。Gets a comparer that can compare two nodes for value equality. |
| NextNode |
获取此节点的下一个同级节点。Gets the next sibling node of this node. |
| NodeType |
获取此 XObject 的节点类型。Gets the node type for this XObject. (继承自 XObject) |
| Parent |
获取此 XObject 的父级 XElement。Gets the parent XElement of this XObject. (继承自 XObject) |
| PreviousNode |
获取此节点的上一个同级节点。Gets the previous sibling node of this node. |
方法
| AddAfterSelf(Object) |
紧跟在此节点之后添加指定的内容。Adds the specified content immediately after this node. |
| AddAfterSelf(Object[]) |
紧跟在此节点之后添加指定的内容。Adds the specified content immediately after this node. |
| AddAnnotation(Object) |
将对象添加到此 XObject 的批注列表。Adds an object to the annotation list of this XObject. (继承自 XObject) |
| AddBeforeSelf(Object) |
紧邻此节点之前添加指定的内容。Adds the specified content immediately before this node. |
| AddBeforeSelf(Object[]) |
紧邻此节点之前添加指定的内容。Adds the specified content immediately before this node. |
| Ancestors() |
返回此节点的上级元素的集合。Returns a collection of the ancestor elements of this node. |
| Ancestors(XName) |
返回此节点的经过筛选的上级元素的集合。Returns a filtered collection of the ancestor elements of this node. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection. |
| Annotation(Type) |
从此 XObject 获取指定类型的第一个批注对象。Gets the first annotation object of the specified type from this XObject. (继承自 XObject) |
| Annotation<T>() |
从此 XObject 获取指定类型的第一个批注对象。Gets the first annotation object of the specified type from this XObject. (继承自 XObject) |
| Annotations(Type) |
获取此 XObject 的指定类型的批注集合。Gets a collection of annotations of the specified type for this XObject. (继承自 XObject) |
| Annotations<T>() |
获取此 XObject 的指定类型的批注集合。Gets a collection of annotations of the specified type for this XObject. (继承自 XObject) |
| CompareDocumentOrder(XNode, XNode) |
比较两个节点以确定其相对的 XML 文档顺序。Compares two nodes to determine their relative XML document order. |
| CreateReader() | |
| CreateReader(ReaderOptions) |
使用 |
| DeepEquals(XNode, XNode) |
比较两个节点的值,包括所有子代节点的值。Compares the values of two nodes, including the values of all descendant nodes. |
| ElementsAfterSelf() |
按文档顺序返回此节点后的同级元素集合。Returns a collection of the sibling elements after this node, in document order. |
| ElementsAfterSelf(XName) |
按文档顺序返回此节点后经过筛选的同级元素的集合。Returns a filtered collection of the sibling elements after this node, in document order. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection. |
| ElementsBeforeSelf() |
按文档顺序返回此节点前的同级元素集合。Returns a collection of the sibling elements before this node, in document order. |
| ElementsBeforeSelf(XName) |
按文档顺序返回此节点前经过筛选的同级元素的集合。Returns a filtered collection of the sibling elements before this node, in document order. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection. |
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| IsAfter(XNode) |
确定当前节点是否按文档顺序显示在指定节点之后。Determines if the current node appears after a specified node in terms of document order. |
| IsBefore(XNode) |
确定当前节点是否按文档顺序显示在指定节点之前。Determines if the current node appears before a specified node in terms of document order. |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| NodesAfterSelf() |
按文档顺序返回此节点后的同级节点的集合。Returns a collection of the sibling nodes after this node, in document order. |
| NodesBeforeSelf() |
按文档顺序返回此节点前的同级节点的集合。Returns a collection of the sibling nodes before this node, in document order. |
| ReadFrom(XmlReader) | |
| ReadFromAsync(XmlReader, CancellationToken) |
从 XmlReader 创建 XNode。Creates an XNode from an XmlReader. 节点的运行时类型由读取器中出现的第一个节点的 NodeType 确定。The runtime type of the node is determined by the NodeType of the first node encountered in the reader. |
| Remove() |
从节点父级中删除此节点。Removes this node from its parent. |
| RemoveAnnotations(Type) |
从此 XObject 移除指定类型的批注。Removes the annotations of the specified type from this XObject. (继承自 XObject) |
| RemoveAnnotations<T>() |
从此 XObject 移除指定类型的批注。Removes the annotations of the specified type from this XObject. (继承自 XObject) |
| ReplaceWith(Object) |
将此节点替换为指定的内容。Replaces this node with the specified content. |
| ReplaceWith(Object[]) |
将此节点替换为指定的内容。Replaces this node with the specified content. |
| ToString() |
返回此节点的缩进 XML。Returns the indented XML for this node. |
| ToString(SaveOptions) |
返回此节点的 XML,还可以选择禁用格式设置。Returns the XML for this node, optionally disabling formatting. |
| WriteTo(XmlWriter) | |
| WriteToAsync(XmlWriter, CancellationToken) |
事件
| Changed |
在此 XObject 或其任何子代发生了更改时引发。Raised when this XObject or any of its descendants have changed. (继承自 XObject) |
| Changing |
当此 XObject 或其任何子代要发生更改时引发。Raised when this XObject or any of its descendants are about to change. (继承自 XObject) |
显式接口实现
| IXmlLineInfo.HasLineInfo() |
获取一个值,该值指示此 XObject 是否具有行信息。Gets a value indicating whether or not this XObject has line information. (继承自 XObject) |
| IXmlLineInfo.LineNumber |
获取基础 XmlReader 为此 XObject 报告的行号。Gets the line number that the underlying XmlReader reported for this XObject. (继承自 XObject) |
| IXmlLineInfo.LinePosition |
获取基础 XmlReader 为此 XObject 报告的行位置。Gets the line position that the underlying XmlReader reported for this XObject. (继承自 XObject) |
扩展方法
| CreateNavigator(XNode) |
为 XPathNavigator 创建一个 XNode。Creates an XPathNavigator for an XNode. |
| CreateNavigator(XNode, XmlNameTable) |
为 XPathNavigator 创建一个 XNode。Creates an XPathNavigator for an XNode. XmlNameTable 可以使 XPath 表达式的处理变得更高效。The XmlNameTable enables more efficient XPath expression processing. |
| XPathEvaluate(XNode, String) |
计算 XPath 表达式。Evaluates an XPath expression. |
| XPathEvaluate(XNode, String, IXmlNamespaceResolver) |
计算 XPath 表达式,使用指定的 IXmlNamespaceResolver 解析命名空间前缀。Evaluates an XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver. |
| XPathSelectElement(XNode, String) |
使用 XPath 表达式选择 XElement。Selects an XElement using a XPath expression. |
| XPathSelectElement(XNode, String, IXmlNamespaceResolver) |
使用 XPath 表达式选择 XElement,并使用指定的 IXmlNamespaceResolver 解析命名空间前缀。Selects an XElement using a XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver. |
| XPathSelectElements(XNode, String) |
使用 XPath 表达式选择一个元素集合。Selects a collection of elements using an XPath expression. |
| XPathSelectElements(XNode, String, IXmlNamespaceResolver) |
使用 XPath 表达式选择一个元素集合,并使用指定的 IXmlNamespaceResolver 解析命名空间前缀。Selects a collection of elements using an XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver. |
| ToXPathNavigable(XNode) |
返回一个访问器,该访问器可用于导航和编辑指定的 XNode。Returns an accessor that allows you to navigate and edit the specified XNode. |