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
[C#]
public virtual bool HasNamespace(
 string prefix
);
[C++]
public: virtual bool HasNamespace(
 String* prefix
);
[JScript]
public function HasNamespace(
   prefix : String
) : Boolean;

Parameters

prefix
The prefix of the namespace you want to find.

Return Value

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

Remarks

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.

Example

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

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

[C#] 
if (nsmgr.HasNamespace(String.Empty))
  Console.WriteLine(nsmgr.DefaultNamespace);

[C++] 
if (nsmgr->HasNamespace(String::Empty))
  Console::WriteLine(nsmgr->DefaultNamespace);

[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.

Requirements

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

Show: