IXmlNamespaceResolver.LookupNamespace(String) 方法

定义

获取映射到指定前缀的命名空间 URI。Gets the namespace URI mapped to the specified prefix.

public:
 System::String ^ LookupNamespace(System::String ^ prefix);
public string LookupNamespace (string prefix);
public string? LookupNamespace (string prefix);
abstract member LookupNamespace : string -> string
Public Function LookupNamespace (prefix As String) As String

参数

prefix
String

要查找其命名空间 URI 的前缀。The prefix whose namespace URI you wish to find.

返回

String

映射到前缀的命名空间 URI;如果前缀未映射到命名空间 URI,则为 nullThe namespace URI that is mapped to the prefix; null if the prefix is not mapped to a namespace URI.

注解

备注

命名空间 URI 到前缀的映射可以更改为 XML 文档中的节点和节点。Namespace URI-to-prefix mappings can change from node to node in an XML document. 不能依赖于从一个节点到下一个节点的查找结果。You cannot depend on the result of a lookup being consistent from one node to the next.

下表介绍方法如何处理默认命名空间和内置命名空间 LookupNamespaceThe following table describes how the default and built-in namespaces are handled by the LookupNamespace method.

前缀Prefix 返回值Return Value
xmlxml http://www.w3.org/XML/1998/namespace
xmlnsxmlns http://www.w3.org/2000/xmlns/
String.Empty (已) 分配默认命名空间。String.Empty (A default namespace has been assigned). 当前分配的默认命名空间。The currently assigned default namespace.
String.Empty (未) 显式分配默认命名空间。String.Empty (The default namespace has not been explicitly assigned). String.Empty (空格前缀与不在任何命名空间) 中的元素相关联。String.Empty (The blank prefix is associated with elements that are not in any namespace).

适用于