XPathNavigator.LookupPrefix Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the prefix declared for the specified namespace URI.

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

public virtual string LookupPrefix(
	string namespaceURI


Type: System.String

The namespace URI to resolve for the prefix.

Return Value

Type: System.String

A String that contains the namespace prefix assigned to the namespace URI specified; otherwise, String.Empty if no prefix is assigned to the namespace URI specified. The String returned is atomized.

The LookupPrefix method returns the first prefix that matches the namespace URI specified. Multiple prefixes referring to the same namespace URI are not ordered in any particular way, so a particular prefix may not be returned each time when more than one is assigned.


Namespace URI to prefix mappings can change from node to node in an XML document. As a result, the value of the LookupPrefix method may not be consistent from one node to the next.

.NET Framework
Available since 2.0
Available since 4.0
Return to top