XPathNavigator.MoveToParent 方法

定義

在衍生類別中覆寫時,將 XPathNavigator 移至目前節點的父節點。

public:
 abstract bool MoveToParent();
public abstract bool MoveToParent ();
abstract member MoveToParent : unit -> bool
Public MustOverride Function MoveToParent () As Boolean

傳回

Boolean

如果 XPathNavigator 成功移至目前節點的父節點,則為 true;否則為 false。 如果為 falseXPathNavigator 的位置就不會變更。

範例

如需 方法的 MoveToParent 範例,請參閱 CreateAttribute 方法。

備註

方法的 MoveToParent 傳回值取決於 XPathNodeType 目前節點的 ,以及 XPathNodeType 要移至之父節點的 。

下表顯示不同的 XPathNodeType 節點,以及其可移至的父節點。

XPathNodeType 父節點
Root Root 節點沒有父代。
Element ElementRoot 節點。
Attribute Element 節點。
Text Element 節點。
Namespace Element 節點。
ProcessingInstruction ElementRoot 節點。
Comment ElementRoot 節點。
Whitespace ElementRoot 節點。
SignificantWhitespace ElementRoot 節點。

適用於