XContainer 类

定义

表示可包含其他节点的节点。Represents a node that can contain other nodes.

public ref class XContainer abstract : System::Xml::Linq::XNode
public abstract class XContainer : System.Xml.Linq.XNode
type XContainer = class
    inherit XNode
Public MustInherit Class XContainer
Inherits XNode
继承
XContainer
派生

注解

此类提供一些功能,例如查找下一个或上一个同级节点,或者枚举节点的直接子级。This class provides functionality such as finding the next or previous sibling node, or enumerating the direct children of a node.

派生自XContainer的两个类为XDocumentXElementThe two classes that derive from XContainer are XDocument and XElement.

属性

BaseUri

获取此 XObject 的基 URI。Gets the base URI for this XObject.

(继承自 XObject)
Document

获取此 XDocumentXObjectGets the XDocument for this XObject.

(继承自 XObject)
FirstNode

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

LastNode

获取此节点的最后一个子节点。Gets the last child node of this node.

NextNode

获取此节点的下一个同级节点。Gets the next sibling node of this node.

(继承自 XNode)
NodeType

获取此 XObject 的节点类型。Gets the node type for this XObject.

(继承自 XObject)
Parent

获取此 XObject 的父级 XElementGets the parent XElement of this XObject.

(继承自 XObject)
PreviousNode

获取此节点的上一个同级节点。Gets the previous sibling node of this node.

(继承自 XNode)

方法

Add(Object)

将指定的内容添加为此 XContainer 的子级。Adds the specified content as children of this XContainer.

Add(Object[])

将指定的内容添加为此 XContainer 的子级。Adds the specified content as children of this XContainer.

AddAfterSelf(Object)

紧跟在此节点之后添加指定的内容。Adds the specified content immediately after this node.

(继承自 XNode)
AddAfterSelf(Object[])

紧跟在此节点之后添加指定的内容。Adds the specified content immediately after this node.

(继承自 XNode)
AddAnnotation(Object)

将对象添加到此 XObject 的批注列表。Adds an object to the annotation list of this XObject.

(继承自 XObject)
AddBeforeSelf(Object)

紧邻此节点之前添加指定的内容。Adds the specified content immediately before this node.

(继承自 XNode)
AddBeforeSelf(Object[])

紧邻此节点之前添加指定的内容。Adds the specified content immediately before this node.

(继承自 XNode)
AddFirst(Object)

将指定内容作为此文档或元素的第一个子级添加。Adds the specified content as the first children of this document or element.

AddFirst(Object[])

将指定内容作为此文档或元素的第一个子级添加。Adds the specified content as the first children of this document or element.

Ancestors()

返回此节点的上级元素的集合。Returns a collection of the ancestor elements of this node.

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

(继承自 XNode)
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)
CreateReader()

创建此节点的 XmlReaderCreates an XmlReader for this node.

(继承自 XNode)
CreateReader(ReaderOptions)

使用 readerOptions 参数指定的选项创建 XmlReaderCreates an XmlReader with the options specified by the readerOptions parameter.

(继承自 XNode)
CreateWriter()

创建可用于将节点添加至 XContainerXmlWriterCreates an XmlWriter that can be used to add nodes to the XContainer.

DescendantNodes()

按文档顺序返回此文档或元素的子代节点集合。Returns a collection of the descendant nodes for this document or element, in document order.

Descendants()

按文档顺序返回此文档或元素的子代元素集合。Returns a collection of the descendant elements for this document or element, in document order.

Descendants(XName)

按文档顺序返回此文档或元素的已筛选的子代元素集合。Returns a filtered collection of the descendant elements for this document or element, in document order. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

Element(XName)

获取具有指定的 XName 的第一个(按文档顺序)子元素。Gets the first (in document order) child element with the specified XName.

Elements()

按文档顺序返回此元素或文档的子元素集合。Returns a collection of the child elements of this element or document, in document order.

Elements(XName)

按文档顺序返回此元素或文档的已筛选的子元素集合。Returns a filtered collection of the child elements of this element or document, in document order. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

ElementsAfterSelf()

按文档顺序返回此节点后的同级元素集合。Returns a collection of the sibling elements after this node, in document order.

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

(继承自 XNode)
ElementsBeforeSelf()

按文档顺序返回此节点前的同级元素集合。Returns a collection of the sibling elements before this node, in document order.

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

(继承自 XNode)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsAfter(XNode)

确定当前节点是否按文档顺序显示在指定节点之后。Determines if the current node appears after a specified node in terms of document order.

(继承自 XNode)
IsBefore(XNode)

确定当前节点是否按文档顺序显示在指定节点之前。Determines if the current node appears before a specified node in terms of document order.

(继承自 XNode)
MemberwiseClone()

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

(继承自 Object)
Nodes()

按文档顺序返回此元素或文档的子节点集合。Returns a collection of the child nodes of this element or document, in document order.

NodesAfterSelf()

按文档顺序返回此节点后的同级节点的集合。Returns a collection of the sibling nodes after this node, in document order.

(继承自 XNode)
NodesBeforeSelf()

按文档顺序返回此节点前的同级节点的集合。Returns a collection of the sibling nodes before this node, in document order.

(继承自 XNode)
Remove()

从节点父级中删除此节点。Removes this node from its parent.

(继承自 XNode)
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)
RemoveNodes()

从此文档或元素中移除子节点。Removes the child nodes from this document or element.

ReplaceNodes(Object)

使用指定内容替换此文档或元素的子节点。Replaces the children nodes of this document or element with the specified content.

ReplaceNodes(Object[])

使用指定内容替换此文档或元素的子节点。Replaces the children nodes of this document or element with the specified content.

ReplaceWith(Object)

使用指定的内容替换此节点。Replaces this node with the specified content.

(继承自 XNode)
ReplaceWith(Object[])

使用指定的内容替换此节点。Replaces this node with the specified content.

(继承自 XNode)
ToString()

返回此节点的缩进 XML。Returns the indented XML for this node.

(继承自 XNode)
ToString(SaveOptions)

返回此节点的 XML,还可以选择禁用格式设置。Returns the XML for this node, optionally disabling formatting.

(继承自 XNode)
WriteTo(XmlWriter)

将此节点写入 XmlWriterWrites this node to an XmlWriter.

(继承自 XNode)
WriteToAsync(XmlWriter, CancellationToken)

将当前节点写入到 XmlWriterWrites the current node to an XmlWriter.

(继承自 XNode)

事件

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 创建一个 XNodeCreates an XPathNavigator for an XNode.

CreateNavigator(XNode, XmlNameTable)

XPathNavigator 创建一个 XNodeCreates 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 表达式选择 XElementSelects 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)

返回一个访问器,该访问器可用于导航和编辑指定的 XNodeReturns an accessor that allows you to navigate and edit the specified XNode.

适用于

另请参阅