XPathNavigator.LookupNamespace(String) Method

Definition

Gets the namespace URI for the specified prefix.

C#
public virtual string? LookupNamespace(string prefix);
C#
public virtual string LookupNamespace(string prefix);

Parameters

prefix
String

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

Returns

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.

Implements

Examples

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

Remarks

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.

Note

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.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1