This documentation is archived and is not being maintained.

XmlNamespaceManager.HasNamespace Method

Gets a value indicating whether the supplied prefix has a namespace defined for the current pushed scope.

[Visual Basic]
Public Overridable Function HasNamespace( _
   ByVal prefix As String _
) As Boolean
public virtual bool HasNamespace(
 string prefix
public: virtual bool HasNamespace(
 String* prefix
public function HasNamespace(
   prefix : String
) : Boolean;


The prefix of the namespace you want to find.

Return Value

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


To determine whether there is a default empty namespace defined, set prefix to String.Empty. If the method returns true, this indicates that there is a default namespace defined in current scope. Returning false indicates that no default namespace is defined.

Note   xmlns:x= "" is illegal according to W3C Namespaces in XML recommendation.


[Visual Basic, C#, C++] The following example displays the default namespace, if one it exists.

[Visual Basic] 
If nsmgr.HasNamespace(String.Empty) Then
End If

if (nsmgr.HasNamespace(String.Empty))

if (nsmgr->HasNamespace(String::Empty))

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

XmlNamespaceManager Class | XmlNamespaceManager Members | System.Xml Namespace