语言

XmlNodeReader.LookupNamespace(String) 方法

定义

解析当前元素作用域中的命名空间前缀。

public:
 override System::String ^ LookupNamespace(System::String ^ prefix);
public override string? LookupNamespace(string prefix);
public override string LookupNamespace(string prefix);
override this.LookupNamespace : string -> string
Public Overrides Function LookupNamespace (prefix As String) As String

参数

prefix
String

要解析其命名空间 URI 的前缀。 若要匹配默认命名空间,请传递空字符串。 此字符串不必原子化。

返回

前缀映射到的命名空间 URI,或者 null 找不到匹配的前缀。

注解

注释

为了利用较新的功能,建议的做法是使用XmlReader类和XmlReaderSettings方法创建Create实例。 有关详细信息,请参阅参考页中的 XmlReader “备注”部分。

在以下 XML 字符串中,如果读取器定位在属性上href,则通过调用来a解析前缀reader.LookupNamespace("a")。 返回的字符串为 urn:456.

<root xmlns:a="urn:456">
 <item>
 <ref href="a:b"/>
 </item>
</root>

适用于