語言

SecurityElement.Attribute(String) 方法

定義

在 XML 元素中依名稱尋找屬性。

public:
 System::String ^ Attribute(System::String ^ name);
public string? Attribute(string name);
public string Attribute(string name);
member this.Attribute : string -> string
Public Function Attribute (name As String) As String

參數

name
String

要搜尋的屬性名稱。

傳回

與所命名屬性相關聯的值,或 null 若不存在屬性, name 則為該值。

例外狀況

參數 name 為 null。

範例

以下程式碼展示了利用 Attribute 此方法透過名稱尋找屬性的方法。 此程式碼範例是本類別更大範例 SecurityElement 的一部分。

string xmlCreationDate = xmlElement.Attribute("creationdate");
Dim xmlCreationDate As String = xmlElement.Attribute("creationdate")

備註

若 XML 格式如下, Attribute("B") 則會回傳「456」。

<thetag A="123" B="456" C="789">text</thetag>

適用於