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 的前置詞。 若要符合預設命名空間,請傳送空字串。 不必擷取這個字串。

傳回

String

前置詞對應的命名空間 URI,如果找不到符合的前置詞,則為 null

備註

注意

在 .NET Framework 2.0 中,建議的做法是使用 XmlReaderSettings 類別和 Create 方法建立 XmlReader 實例。 這可讓您充分利用.NET Framework中引進的所有新功能。 如需詳細資訊,請參閱參考頁面中的 XmlReader 一節。

在下列 XML 字串中,如果讀取器位於 屬性上 href ,則會呼叫 reader.LookupNamespace("a") 來解析前置詞 a 。 傳回的字串為 urn:456

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

適用於