XmlReader.LookupNamespace(String) 方法

定义

在派生类中重写时,解析当前元素作用域中的命名空间前缀。

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

参数

prefix
String

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

返回

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

例外

在上一个异步操作完成之前调用了一个 XmlReader 方法。 在这种情况下, InvalidOperationException 会引发消息“正在进行异步操作”。

注解

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

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

适用于