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

要搜尋的屬性名稱。

傳回

與具名屬性相關的數值,或如果具有 name 的屬性不存在,則為 null

例外狀況

name 參數為 null

範例

下列程式碼示範如何使用 Attribute 方法來依名稱尋找屬性。 此程式碼範例是針對 類別提供的較大範例的 SecurityElement 一部分。

String^ xmlCreationDate = xmlElement->Attribute(L"creationdate");
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>  

適用於