语言

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>

适用于