XPathNavigator 类

定义

为定位和编辑 XML 数据提供游标模型。Provides a cursor model for navigating and editing XML data.

public ref class XPathNavigator abstract : System::Xml::XPath::XPathItem, ICloneable, System::Xml::IXmlNamespaceResolver, System::Xml::XPath::IXPathNavigable
public abstract class XPathNavigator : System.Xml.XPath.XPathItem, ICloneable, System.Xml.IXmlNamespaceResolver, System.Xml.XPath.IXPathNavigable
type XPathNavigator = class
    inherit XPathItem
    interface ICloneable
    interface IXPathNavigable
    interface IXmlNamespaceResolver
Public MustInherit Class XPathNavigator
Inherits XPathItem
Implements ICloneable, IXmlNamespaceResolver, IXPathNavigable
继承
XPathNavigator
派生
实现

注解

命名System.Xml.XPath空间中的XPathNavigator类是一个抽象类,用于定义用于导航和编辑 XML 信息项作为 XQuery 1.0 和 XPath 2.0 数据模型的实例的游标模型。The XPathNavigator class in the System.Xml.XPath namespace is an abstract class which defines a cursor model for navigating and editing XML information items as instances of the XQuery 1.0 and XPath 2.0 Data Model.

对象是从IXPathNavigable实现接口的类(如XPathDocumentXmlDocument类)创建的。 XPathNavigatorAn XPathNavigator object is created from a class that implements the IXPathNavigable interface such as the XPathDocument and XmlDocument classes. XPathNavigator对象创建XPathDocument的对象是只读的,而XPathNavigator对象创建的XmlDocument对象可以进行编辑。XPathNavigator objects created by XPathDocument objects are read-only while XPathNavigator objects created by XmlDocument objects can be edited. 对象的只读或可编辑状态是CanEdit使用XPathNavigator类的属性确定的。 XPathNavigatorAn XPathNavigator object's read-only or editable status is determined using the CanEdit property of the XPathNavigator class.

有关使用 XPath 数据模型处理 XML 数据的详细信息,请参阅使用 Xpath 数据模型处理 Xml 数据主题。For more information about processing XML data using the XPath data model, see the Process XML Data Using the XPath Data Model topic.

重要

由于使用XPathNavigator类(如XPathException类)而引发的异常可能包含不应在不受信任的方案中公开的敏感信息。Exceptions raised as a result of using the XPathNavigator class, such as the XPathException class, may contain sensitive information that should not be exposed in untrusted scenarios. 应正确处理异常,以便不受信任的情况下不公开此敏感信息。Exceptions should be properly handled so that this sensitive information is not exposed in untrusted scenarios.

实施者说明

XPathNavigator类继承时,必须重写以下成员:When you inherit from the XPathNavigator class, you must override the following members:

构造函数

XPathNavigator()

初始化 XPathNavigator 类的新实例。Initializes a new instance of the XPathNavigator class.

属性

BaseURI

当在派生类中被重写时,获取当前节点的基 URI。When overridden in a derived class, gets the base URI for the current node.

CanEdit

获取一个值,该值指示 XPathNavigator 是否可以编辑基础 XML 数据。Gets a value that indicates whether the XPathNavigator can edit the underlying XML data.

HasAttributes

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

HasChildren

获取一个值,该值指示当前节点是否有任何子节点。Gets a value that indicates whether the current node has any child nodes.

InnerXml

获取或设置表示当前节点的子节点标记。Gets or sets the markup representing the child nodes of the current node.

IsEmptyElement

当在派生类中被重写时,获取一个值,该值指示当前节点是否是一个没有结束元素标记的空元素。When overridden in a derived class, gets a value that indicates whether the current node is an empty element without an end element tag.

IsNode

获取一个值,该值指示当前节点是否表示一个 XPath 节点。Gets a value that indicates if the current node represents an XPath node.

LocalName

当在派生类中被重写时,获取当前节点的不带命名空间前缀的 NameWhen overridden in a derived class, gets the Name of the current node without any namespace prefix.

Name

当在派生类中被重写时,获取当前节点的限定名。When overridden in a derived class, gets the qualified name of the current node.

NamespaceURI

当在派生类中被重写时,获取当前节点的命名空间 URI。When overridden in a derived class, gets the namespace URI of the current node.

NameTable

当在派生类中被重写时,获取 XmlNameTableXPathNavigatorWhen overridden in a derived class, gets the XmlNameTable of the XPathNavigator.

NavigatorComparer

获取一个用于 IEqualityComparer 对象的相等比较的 XPathNavigatorGets an IEqualityComparer used for equality comparison of XPathNavigator objects.

NodeType

当在派生类中被重写时,获取当前节点的 XPathNodeTypeWhen overridden in a derived class, gets the XPathNodeType of the current node.

OuterXml

获取或设置表示当前节点及其子节点的开始标记及结束标记的标记。Gets or sets the markup representing the opening and closing tags of the current node and its child nodes.

Prefix

当在派生类中被重写时,获取与当前节点关联的命名空间前缀。When overridden in a derived class, gets the namespace prefix associated with the current node.

SchemaInfo

获取作为架构验证结果分配给当前节点的架构信息。Gets the schema information that has been assigned to the current node as a result of schema validation.

TypedValue

获取作为最合适的 .NET Framework 类型的已装箱对象的当前节点。Gets the current node as a boxed object of the most appropriate .NET Framework type.

UnderlyingObject

由在存储区上提供“虚拟化”XML 视图的 XPathNavigator 实现使用,以提供对基础对象的访问。Used by XPathNavigator implementations which provide a "virtualized" XML view over a store, to provide access to underlying objects.

Value

当在派生类中重写时,获取该项的字符串值。When overridden in a derived class, gets the string value of the item.

ValueAsBoolean

获取当前节点的 Boolean 类型的值。Gets the current node's value as a Boolean.

ValueAsDateTime

获取当前节点的 DateTime 类型的值。Gets the current node's value as a DateTime.

ValueAsDouble

获取当前节点的 Double 类型的值。Gets the current node's value as a Double.

ValueAsInt

获取当前节点的 Int32 类型的值。Gets the current node's value as an Int32.

ValueAsLong

获取当前节点的 Int64 类型的值。Gets the current node's value as an Int64.

ValueType

获取当前节点的 .NET Framework TypeGets the .NET Framework Type of the current node.

XmlLang

获取当前节点的 xml:lang 范围。Gets the xml:lang scope for the current node.

XmlType

获取当前节点的 XmlSchemaType 信息。Gets the XmlSchemaType information for the current node.

方法

AppendChild()

返回一个 XmlWriter 对象,该对象用于在当前节点的子节点列表的末尾创建一个或多个新的子节点。Returns an XmlWriter object used to create one or more new child nodes at the end of the list of child nodes of the current node.

AppendChild(String)

使用指定的 XML 数据字符串在当前节点的子节点列表的末尾创建一个新的子节点。Creates a new child node at the end of the list of child nodes of the current node using the XML data string specified.

AppendChild(XmlReader)

使用指定的 XmlReader 对象的 XML 内容在当前节点的子节点列表的末尾创建一个新的子节点。Creates a new child node at the end of the list of child nodes of the current node using the XML contents of the XmlReader object specified.

AppendChild(XPathNavigator)

使用指定的 XPathNavigator 中的节点在当前节点的子节点列表的末尾创建一个新的子节点。Creates a new child node at the end of the list of child nodes of the current node using the nodes in the XPathNavigator specified.

AppendChildElement(String, String, String, String)

使用通过指定值指定的命名空间前缀、本地名称和命名空间 URI 在当前节点的子节点列表的末尾创建一个新的子元素节点。Creates a new child element node at the end of the list of child nodes of the current node using the namespace prefix, local name and namespace URI specified with the value specified.

CheckValidity(XmlSchemaSet, ValidationEventHandler)

验证 XPathNavigator 中的 XML 数据是否符合所提供的 XML 架构定义语言 (XSD) 架构。Verifies that the XML data in the XPathNavigator conforms to the XML Schema definition language (XSD) schema provided.

Clone()

当在派生类中被重写时,创建一个新的 XPathNavigator,它定位到的节点与此 XPathNavigator 定位到的节点相同。When overridden in a derived class, creates a new XPathNavigator positioned at the same node as this XPathNavigator.

ComparePosition(XPathNavigator)

将当前 XPathNavigator 的位置与指定的 XPathNavigator 的位置进行比较。Compares the position of the current XPathNavigator with the position of the XPathNavigator specified.

Compile(String)

编译一个表示 XPath 表达式的字符串,并返回 XPathExpression 对象。Compiles a string representing an XPath expression and returns an XPathExpression object.

CreateAttribute(String, String, String, String)

使用通过指定值指定的命名空间前缀、本地名称和命名空间 URI 在当前元素节点上创建一个属性节点。Creates an attribute node on the current element node using the namespace prefix, local name and namespace URI specified with the value specified.

CreateAttributes()

返回一个 XmlWriter 对象,该对象用于在当前元素上创建一个新属性。Returns an XmlWriter object used to create new attributes on the current element.

CreateNavigator()

返回 XPathNavigator 的一个副本。Returns a copy of the XPathNavigator.

DeleteRange(XPathNavigator)

删除从当前节点到指定节点之间的一组同级节点。Deletes a range of sibling nodes from the current node to the node specified.

DeleteSelf()

删除当前节点及其子节点。Deletes the current node and its child nodes.

Equals(Object)

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

(继承自 Object)
Evaluate(String)

计算指定的 XPath 表达式并返回类型化结果。Evaluates the specified XPath expression and returns the typed result.

Evaluate(String, IXmlNamespaceResolver)

计算指定的 XPath 表达式并返回类型化结果,以使用指定的 IXmlNamespaceResolver 对象解析 XPath 表达式中的命名空间前缀。Evaluates the specified XPath expression and returns the typed result, using the IXmlNamespaceResolver object specified to resolve namespace prefixes in the XPath expression.

Evaluate(XPathExpression)

计算 XPathExpression 并返回类型化结果。Evaluates the XPathExpression and returns the typed result.

Evaluate(XPathExpression, XPathNodeIterator)

使用提供的上下文计算 XPathExpression,并返回类型化结果。Uses the supplied context to evaluate the XPathExpression, and returns the typed result.

GetAttribute(String, String)

获取具有指定本地名称和命名空间 URI 的属性的值。Gets the value of the attribute with the specified local name and namespace URI.

GetHashCode()

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

(继承自 Object)
GetNamespace(String)

返回与所指定本地名称对应的命名空间节点的值。Returns the value of the namespace node corresponding to the specified local name.

GetNamespacesInScope(XmlNamespaceScope)

返回当前节点的范围内命名空间。Returns the in-scope namespaces of the current node.

GetType()

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

(继承自 Object)
InsertAfter()

返回一个 XmlWriter 对象,该对象用于在当前选定的节点之后创建一个新的同级节点。Returns an XmlWriter object used to create a new sibling node after the currently selected node.

InsertAfter(String)

使用指定的 XML 字符串在当前选定的节点之后创建一个新的同级节点。Creates a new sibling node after the currently selected node using the XML string specified.

InsertAfter(XmlReader)

使用指定的 XmlReader 对象的 XML 内容在当前选定的节点之后创建一个新的同级节点。Creates a new sibling node after the currently selected node using the XML contents of the XmlReader object specified.

InsertAfter(XPathNavigator)

使用指定的 XPathNavigator 对象中的节点在当前选定的节点之后创建一个新的同级节点。Creates a new sibling node after the currently selected node using the nodes in the XPathNavigator object specified.

InsertBefore()

返回一个 XmlWriter 对象,该对象用于在当前选定的节点之前创建一个新的同级节点。Returns an XmlWriter object used to create a new sibling node before the currently selected node.

InsertBefore(String)

使用指定的 XML 字符串在当前选定的节点之前创建一个新的同级节点。Creates a new sibling node before the currently selected node using the XML string specified.

InsertBefore(XmlReader)

使用指定的 XmlReader 对象的 XML 内容在当前选定的节点之前创建一个新的同级节点。Creates a new sibling node before the currently selected node using the XML contents of the XmlReader object specified.

InsertBefore(XPathNavigator)

使用指定的 XPathNavigator 中的节点在当前选定的节点之前创建一个新的同级节点。Creates a new sibling node before the currently selected node using the nodes in the XPathNavigator specified.

InsertElementAfter(String, String, String, String)

使用通过指定值指定的命名空间前缀、本地名称和命名空间 URI 在当前节点之后创建一个新的同级元素。Creates a new sibling element after the current node using the namespace prefix, local name and namespace URI specified, with the value specified.

InsertElementBefore(String, String, String, String)

使用通过指定值指定的命名空间前缀、本地名称和命名空间 URI 在当前节点之前创建一个新的同级元素。Creates a new sibling element before the current node using the namespace prefix, local name, and namespace URI specified, with the value specified.

IsDescendant(XPathNavigator)

确定指定的 XPathNavigator 是否是当前 XPathNavigator 的子代。Determines whether the specified XPathNavigator is a descendant of the current XPathNavigator.

IsSamePosition(XPathNavigator)

当在派生类中被重写时,确定当前的 XPathNavigator 是否位于与指定的 XPathNavigator 相同的位置。When overridden in a derived class, determines whether the current XPathNavigator is at the same position as the specified XPathNavigator.

LookupNamespace(String)

获取指定前缀的命名空间 URI。Gets the namespace URI for the specified prefix.

LookupPrefix(String)

获取为指定的命名空间 URI 声明的前缀。Gets the prefix declared for the specified namespace URI.

Matches(String)

确定当前节点是否与指定的 XPath 表达式匹配。Determines whether the current node matches the specified XPath expression.

Matches(XPathExpression)

确定当前节点是否匹配指定的 XPathExpressionDetermines whether the current node matches the specified XPathExpression.

MemberwiseClone()

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

(继承自 Object)
MoveTo(XPathNavigator)

当在派生类中被重写时,将 XPathNavigator 移动到与指定的 XPathNavigator 相同的位置。When overridden in a derived class, moves the XPathNavigator to the same position as the specified XPathNavigator.

MoveToAttribute(String, String)

XPathNavigator 移动到具有匹配的本地名称和命名空间 URI 的属性上。Moves the XPathNavigator to the attribute with the matching local name and namespace URI.

MoveToChild(String, String)

XPathNavigator 移动到具有指定的本地名称和命名空间 URI 的子节点。Moves the XPathNavigator to the child node with the local name and namespace URI specified.

MoveToChild(XPathNodeType)

XPathNavigator 移动到指定的 XPathNodeType 的子节点。Moves the XPathNavigator to the child node of the XPathNodeType specified.

MoveToFirst()

XPathNavigator 移至当前节点的第一个同级节点。Moves the XPathNavigator to the first sibling node of the current node.

MoveToFirstAttribute()

当在派生类中重写时,将 XPathNavigator 移动到当前节点的第一个属性。When overridden in a derived class, moves the XPathNavigator to the first attribute of the current node.

MoveToFirstChild()

当在派生类中被重写时,将 XPathNavigator 移动到当前节点的第一个子节点。When overridden in a derived class, moves the XPathNavigator to the first child node of the current node.

MoveToFirstNamespace()

XPathNavigator 移动到当前节点的第一个命名空间节点。Moves the XPathNavigator to first namespace node of the current node.

MoveToFirstNamespace(XPathNamespaceScope)

当在派生类中被重写时,将 XPathNavigator 移动到与指定的 XPathNamespaceScope 匹配的第一个命名空间节点。When overridden in a derived class, moves the XPathNavigator to the first namespace node that matches the XPathNamespaceScope specified.

MoveToFollowing(String, String)

按文档顺序将 XPathNavigator 移动到具有指定的本地名称和命名空间 URI 的元素。Moves the XPathNavigator to the element with the local name and namespace URI specified in document order.

MoveToFollowing(String, String, XPathNavigator)

按文档顺序将 XPathNavigator 移动到指定的边界内具有指定的本地名称和命名空间 URI 的元素。Moves the XPathNavigator to the element with the local name and namespace URI specified, to the boundary specified, in document order.

MoveToFollowing(XPathNodeType)

按文档顺序将 XPathNavigator 移动到下一个属于指定 XPathNodeType 的元素。Moves the XPathNavigator to the following element of the XPathNodeType specified in document order.

MoveToFollowing(XPathNodeType, XPathNavigator)

按文档顺序将 XPathNavigator 移动到指定边界内下一个属于指定 XPathNodeType 的元素。Moves the XPathNavigator to the following element of the XPathNodeType specified, to the boundary specified, in document order.

MoveToId(String)

当在派生类中重写时,移动到具有 ID 类型的属性并且属性值与指定的 String 匹配的节点。When overridden in a derived class, moves to the node that has an attribute of type ID whose value matches the specified String.

MoveToNamespace(String)

XPathNavigator 移动到具有指定的命名空间前缀的命名空间节点。Moves the XPathNavigator to the namespace node with the specified namespace prefix.

MoveToNext()

当在派生类中被重写时,将 XPathNavigator 移动到当前节点的下一个同级节点。When overridden in a derived class, moves the XPathNavigator to the next sibling node of the current node.

MoveToNext(String, String)

XPathNavigator 移动到下一个具有指定的本地名称和命名空间 URI 的同级节点。Moves the XPathNavigator to the next sibling node with the local name and namespace URI specified.

MoveToNext(XPathNodeType)

XPathNavigator 移动到当前节点中与指定的 XPathNodeType 匹配的下一个同级节点。Moves the XPathNavigator to the next sibling node of the current node that matches the XPathNodeType specified.

MoveToNextAttribute()

当在派生类中被重写时,将 XPathNavigator 移动到下一个属性。When overridden in a derived class, moves the XPathNavigator to the next attribute.

MoveToNextNamespace()

XPathNavigator 移动到下一个命名空间节点。Moves the XPathNavigator to the next namespace node.

MoveToNextNamespace(XPathNamespaceScope)

当在派生类中被重写时,将 XPathNavigator 移动到与指定的 XPathNamespaceScope 匹配的下一个命名空间节点。When overridden in a derived class, moves the XPathNavigator to the next namespace node matching the XPathNamespaceScope specified.

MoveToParent()

当在派生类中被重写时,将 XPathNavigator 移动到当前节点的父节点。When overridden in a derived class, moves the XPathNavigator to the parent node of the current node.

MoveToPrevious()

当在派生类中被重写时,将 XPathNavigator 移动到当前节点的上一个同级节点。When overridden in a derived class, moves the XPathNavigator to the previous sibling node of the current node.

MoveToRoot()

XPathNavigator 移动到当前节点所属的根节点。Moves the XPathNavigator to the root node that the current node belongs to.

PrependChild()

返回一个 XmlWriter 对象,该对象用于在当前节点的子节点列表的开始处创建一个新的子节点。Returns an XmlWriter object used to create a new child node at the beginning of the list of child nodes of the current node.

PrependChild(String)

使用指定的 XML 字符串在当前节点的子节点列表的开始处创建一个新的子节点。Creates a new child node at the beginning of the list of child nodes of the current node using the XML string specified.

PrependChild(XmlReader)

使用指定的 XmlReader 对象的 XML 内容在当前节点的子节点列表的开始处创建一个新的子节点。Creates a new child node at the beginning of the list of child nodes of the current node using the XML contents of the XmlReader object specified.

PrependChild(XPathNavigator)

使用指定的 XPathNavigator 对象中的节点在当前节点的子节点列表的开始处创建一个新的子节点。Creates a new child node at the beginning of the list of child nodes of the current node using the nodes in the XPathNavigator object specified.

PrependChildElement(String, String, String, String)

使用通过指定值指定的命名空间前缀、本地名称和命名空间 URI 在当前节点的子节点列表的开始处创建一个新的子节点。Creates a new child element at the beginning of the list of child nodes of the current node using the namespace prefix, local name, and namespace URI specified with the value specified.

ReadSubtree()

返回一个 XmlReader 对象,该对象包含当前节点及其子节点。Returns an XmlReader object that contains the current node and its child nodes.

ReplaceRange(XPathNavigator)

替换从当前节点到指定节点之间的一组同级节点。Replaces a range of sibling nodes from the current node to the node specified.

ReplaceSelf(String)

将当前节点替换为指定的字符串内容。Replaces the current node with the content of the string specified.

ReplaceSelf(XmlReader)

将当前节点替换为指定的 XmlReader 对象的内容。Replaces the current node with the contents of the XmlReader object specified.

ReplaceSelf(XPathNavigator)

将当前节点替换为指定的 XPathNavigator 对象的内容。Replaces the current node with the contents of the XPathNavigator object specified.

Select(String)

使用指定的 XPath 表达式选择节点集。Selects a node set, using the specified XPath expression.

Select(String, IXmlNamespaceResolver)

通过指定的 IXmlNamespaceResolver 对象使用指定的 XPath 表达式来选择节点集,以解析命名空间前缀。Selects a node set using the specified XPath expression with the IXmlNamespaceResolver object specified to resolve namespace prefixes.

Select(XPathExpression)

使用指定的 XPathExpression 来选择节点集。Selects a node set using the specified XPathExpression.

SelectAncestors(String, String, Boolean)

选择当前节点中具有指定的本地名称和命名空间 URI 的所有上级节点。Selects all the ancestor nodes of the current node that have the specified local name and namespace URI.

SelectAncestors(XPathNodeType, Boolean)

选择当前节点中具有匹配的 XPathNodeType 的所有上级节点。Selects all the ancestor nodes of the current node that have a matching XPathNodeType.

SelectChildren(String, String)

选择当前节点中具有指定的本地名称和命名空间 URI 的所有子节点。Selects all the child nodes of the current node that have the local name and namespace URI specified.

SelectChildren(XPathNodeType)

选择当前节点中具有匹配的 XPathNodeType 的所有子节点。Selects all the child nodes of the current node that have the matching XPathNodeType.

SelectDescendants(String, String, Boolean)

选择当前节点中具有指定的本地名称和命名空间 URI 的所有子代节点。Selects all the descendant nodes of the current node with the local name and namespace URI specified.

SelectDescendants(XPathNodeType, Boolean)

选择当前节点中具有匹配的 XPathNodeType 的所有子代节点。Selects all the descendant nodes of the current node that have a matching XPathNodeType.

SelectSingleNode(String)

使用指定的 XPath 查询选择 XPathNavigator 中的单个节点。Selects a single node in the XPathNavigator using the specified XPath query.

SelectSingleNode(String, IXmlNamespaceResolver)

通过指定的 XPathNavigator 对象使用指定的 XPath 查询在 IXmlNamespaceResolver 中选择单个节点,以解析命名空间前缀。Selects a single node in the XPathNavigator object using the specified XPath query with the IXmlNamespaceResolver object specified to resolve namespace prefixes.

SelectSingleNode(XPathExpression)

使用指定的 XPathNavigator 对象在 XPathExpression 中选择单个节点。Selects a single node in the XPathNavigator using the specified XPathExpression object.

SetTypedValue(Object)

设置当前节点的类型值。Sets the typed value of the current node.

SetValue(String)

设置当前节点的值。Sets the value of the current node.

ToString()

获取当前节点的文本值。Gets the text value of the current node.

ValueAs(Type, IXmlNamespaceResolver)

获取当前节点的指定 Type 形式的值,以使用指定的 IXmlNamespaceResolver 对象解析命名空间前缀。Gets the current node's value as the Type specified, using the IXmlNamespaceResolver object specified to resolve namespace prefixes.

WriteSubtree(XmlWriter)

使当前节点及其子节点流向指定的 XmlWriter 对象。Streams the current node and its child nodes to the XmlWriter object specified.

显式界面实现

ICloneable.Clone()

创建 XPathNavigator 对象的新副本。Creates a new copy of the XPathNavigator object.

适用于

另请参阅