XmlNamespaceManager.HasNamespace(String) Method
Definition
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))
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
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈