XPathNavigator.LookupNamespace 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 namespace URI for the specified prefix.

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

public virtual string LookupNamespace(
	string prefix


Type: System.String

The prefix whose namespace URI you want to resolve. To match the default namespace, pass String.Empty.

Return Value

Type: System.String

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

If String.Empty is specified as the prefix parameter, the currently assigned default namespace URI is returned. If no default namespace URI is explicitly assigned, and String.Empty is specified as the prefix parameter, the blank prefix is associated with elements that are not in any namespace, and String.Empty is returned.


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

For an example of the LookupNamespace method, see the InsertElementAfter or InsertElementBefore methods.

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