XmlReader.LookupNamespace(String) XmlReader.LookupNamespace(String) XmlReader.LookupNamespace(String) XmlReader.LookupNamespace(String) Method

定义

当在派生类中被重写时,在当前元素的范围内解析命名空间前缀。When overridden in a derived class, resolves a namespace prefix in the current element's scope.

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

参数

prefix
String String String String

要解析其命名空间 URI 的前缀。The prefix whose namespace URI you want to resolve. 若要匹配默认命名空间,请传递一个空字符串。To match the default namespace, pass an empty string.

返回

前缀映射到的命名空间 URI;如果未找到任何匹配的前缀,则为 nullThe namespace URI to which the prefix maps or null if no matching prefix is found.

异常

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader method was called before a previous asynchronous operation finished. 在此情况下,会引发 InvalidOperationException 并显示消息“异步操作已在进行中。”In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

注解

如果读取器定位在以下 XML 字符串中href属性,该前缀a解析通过调用reader.LookupNamespace("a")In the following XML string, if the reader is positioned on the href attribute, the prefix a is resolved by calling reader.LookupNamespace("a"). 返回的字符串是urn:456The returned string is urn:456.

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

适用于