Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XPathNavigator.MoveToFirstNamespace Method (XPathNamespaceScope)

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

Namespace: System.Xml.XPath
Assembly: System.Xml (in system.xml.dll)

public abstract bool MoveToFirstNamespace (
	XPathNamespaceScope namespaceScope
)
public abstract boolean MoveToFirstNamespace (
	XPathNamespaceScope namespaceScope
)
public abstract function MoveToFirstNamespace (
	namespaceScope : XPathNamespaceScope
) : boolean
Not applicable.

Parameters

namespaceScope

An XPathNamespaceScope value describing the namespace scope.

Return Value

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

The XPathNavigator class returns namespace nodes in reverse document order. Therefore, MoveToFirstNamespace essentially moves to the last namespace node in the current scope.

Using the following XML fragment as an example, if the XPathNavigator is positioned on the data node, MoveToFirstNamespace 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.

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

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

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

After the XPathNavigator is positioned on an namespace node, call 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.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft