System.Xml.XPath.XPathNavigator.MoveToFirstNamespace Method

When overridden in a derived class, moves the System.Xml.XPath.XPathNavigator to the first namespace node that matches the System.Xml.XPath.XPathNamespaceScope specified.

Syntax

public abstract bool MoveToFirstNamespace (XPathNamespaceScope namespaceScope)

Parameters

namespaceScope
An System.Xml.XPath.XPathNamespaceScope value describing the namespace scope.

Returns

Returns true if the System.Xml.XPath.XPathNavigator is successful moving to the first namespace node; otherwise, false. If false, the position of the System.Xml.XPath.XPathNavigator is unchanged.

Remarks

The System.Xml.XPath.XPathNavigator class returns namespace nodes in reverse document order. Therefore, XPathNavigator.MoveToFirstNamespace(XPathNamespaceScope) essentially moves to the last namespace node in the current scope.

Using the following XML fragment as an example, if the System.Xml.XPath.XPathNavigator is positioned on the data node, XPathNavigator.MoveToFirstNamespace(XPathNamespaceScope) behaves in the following manner.

  • MoveToFirstNamespace(XPathNamespaceScope.All) moves to one of the following namespace nodes: xmlns:c='C', xmlns:a='A2', xmlns='', xmlns:b='B', or xmlns:xml='http://www.w3.org/XML/1998/namespace'.

  • MoveToFirstNamespace(XPathNamespaceScope.ExcludeXml) moves to one of the following namespace nodes: xmlns:c='C', xmlns:a='A2', xmlns='', or xmlns:b='B'.

  • MoveToFirstNamespace(XPathNamespaceScope.Local) moves to the xmlns:c='C' node.

Example

<root xmlns='urn:default' xmlns:a='A1' xmlns:b='B'>
    <item xmlns='' xmlns:a='A2'>
        <data xmlns:c='C' />
    </item>
</root>

If the System.Xml.XPath.XPathNavigator is not currently positioned on an element, this method returns false and the position of the System.Xml.XPath.XPathNavigator does not change. After the System.Xml.XPath.XPathNavigator has been moved to the namespace node, the XPathNavigator.Name property reflects the name of the namespace.

When the System.Xml.XPath.XPathNavigator is positioned on a namespace node, the methods XPathNavigator.MoveToNext, XPathNavigator.MoveToPrevious, and XPathNavigator.MoveToFirst are not applicable. These methods always return false and do not change the position of the System.Xml.XPath.XPathNavigator. Rather, you can call XPathNavigator.MoveToNextNamespace to move to the next namespace node.

After the System.Xml.XPath.XPathNavigator is positioned on an namespace node, call XPathNavigator.MoveToParent to move back to the element node.

For a definition of namespace nodes, see section 5.4 of the W3C XML Path Language (XPath) recommendation located at http://www.w3.org/TR/xpath#data-model.

Requirements

Namespace: System.Xml.XPath
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0