XmlNamespaceManager.HasNamespace 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 a value indicating whether the supplied prefix has a namespace defined for the current pushed scope.

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

abstract HasNamespace : 
        prefix:string -> bool
override HasNamespace : 
        prefix:string -> bool


Type: System.String

The prefix of the namespace you want to find.

Return Value

Type: System.Boolean

true if there is a namespace defined; otherwise, false.

To determine whether there is a default empty namespace defined, set prefix to String.Empty. A return value of true indicates that there is a default namespace defined in the current scope; false indicates that no default namespace is defined.


xmlns:x= "" is illegal according to the W3C Namespaces recommendation.

The following example displays the default namespace, if one exists.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top