XmlTextReader.GetNamespacesInScope(XmlNamespaceScope) 方法

定義

會獲得包含目前範圍內所有命名空間的集合。

public:
 System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ GetNamespacesInScope(System::Xml::XmlNamespaceScope scope);
public System.Collections.Generic.IDictionary<string,string> GetNamespacesInScope(System.Xml.XmlNamespaceScope scope);
member this.GetNamespacesInScope : System.Xml.XmlNamespaceScope -> System.Collections.Generic.IDictionary<string, string>
Public Function GetNamespacesInScope (scope As XmlNamespaceScope) As IDictionary(Of String, String)

參數

scope
XmlNamespaceScope

一個 XmlNamespaceScope 指定要回傳哪種命名空間節點類型的值。

傳回

一個 IDictionary 包含所有目前範圍內命名空間的物件。 若讀取者未被定位於某元素,則會回傳一個空字典(無命名空間)。

備註

Note

建議您使用 XmlReader 方法來建立XmlReader.Create實例,以利用新功能。

字典由一組以前綴標示的命名空間名稱組成。 它可用來枚舉作用範圍內的命名空間。 字典是閱讀器命名空間清單的獨立副本。 隨著讀取器位置(目前範圍內的命名空間清單)變動,該名稱保持不變。

下表說明列舉值如何XmlNamespaceScope影響預設及內建命名空間是否被回傳。GetNamespacesInScope

XmlNamespaceScope 值 XMLNS:XML XMLns:XMLSNS XMLns=“”
All
ExcludeXml
Local

適用於

另請參閱