SecurityElement.SearchForTextOfTag(String) Метод

Определение

Находит дочерний объект по имени тега и возвращает содержащийся текст.

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

Параметры

tag
String

Тег, для которого выполняется поиск в дочерних элементах.

Возвращаемое значение

Текстовое содержимое первого дочернего элемента с указанным значением тега.

Исключения

tag равно null.

Примеры

В следующем коде показано использование метода для поиска дочернего SearchForTextOfTag элемента по имени тега и возврата содержащегося текста. Этот пример кода является частью более крупного примера, предоставленного для SecurityElement класса.

string storedDestroyTime =
    localXmlElement.SearchForTextOfTag("destroytime");
Dim storedDestroyTime As String = localXmlElement.SearchForTextOfTag("destroytime")

Комментарии

Этот метод эквивалентен следующему:

string SearchForTextOfTag(string tag)
{
    SecurityElement element = this.SearchForChildByTag(tag);
    return element.Text;
}
Public Function SearchForTextOfTag(ByVal tag As String) As String
    Dim element As SecurityElement = MyClass.SearchForChildByTag(tag)
    Return element.Text
End Function

В xml, как показано ниже, SearchForTextOfTag("second") возвращается "text2".

<thetag A="123" B="456" C="789"> <first>text1</first>
    <second>text2</second></thetag>

Применяется к