Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

XmlNamespaceManager.HasNamespace(String) Method

Definition

Namespace:
System.Xml
Assemblies:
System.Xml.dll, System.Xml.ReaderWriter.dll
Assemblies:
netstandard.dll, System.Xml.ReaderWriter.dll
Assembly:
System.Xml.ReaderWriter.dll
Assembly:
System.Xml.dll
Assembly:
netstandard.dll
Source:
XmlNamespacemanager.cs
Source:
XmlNamespacemanager.cs
Source:
XmlNamespacemanager.cs
Source:
XmlNamespacemanager.cs
Source:
XmlNamespacemanager.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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

public:
 virtual bool HasNamespace(System::String ^ prefix);
public virtual bool HasNamespace(string prefix);
abstract member HasNamespace : string -> bool
override this.HasNamespace : string -> bool
Public Overridable Function HasNamespace (prefix As String) As Boolean

Parameters

prefix
String

The prefix of the namespace you want to find.

Returns

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

Examples

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

if (nsmgr.HasNamespace(String.Empty))
 Console.WriteLine(nsmgr.DefaultNamespace);
If nsmgr.HasNamespace(String.Empty) Then
 Console.WriteLine(nsmgr.DefaultNamespace)
End If

Remarks

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.

Note

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

Applies to

See also


Feedback

Was this page helpful?