語言

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 若未找到匹配前綴。

備註

Note

為了利用新功能,建議的做法是使用XmlReader該類別和該XmlReaderSettings方法來建立Create實例。 欲了解更多資訊,請參閱參考頁面的 XmlReader 備註區。

在接下來的 XML 字串中,若讀取器位於屬性上href,則透過呼叫 a來解析前綴reader.LookupNamespace("a")。 回傳的字串為 urn:456。

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

適用於