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>  

适用于