SecurityElement.SearchForTextOfTag(String) Método

Definição

Encontra uma criança pelo nome da etiqueta e devolve o texto contido.

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

Parâmetros

tag
String

A etiqueta para pesquisar elementos filhos.

Devoluções

O conteúdo do texto do primeiro elemento filho com o valor da etiqueta especificado.

Exceções

tag é null.

Exemplos

O código seguinte mostra a utilização do SearchForTextOfTag método para encontrar uma criança pelo nome da etiqueta e devolver o texto contido. Este exemplo de código faz parte de um exemplo maior fornecido para a SecurityElement classe.

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

Observações

Este método é equivalente ao seguinte:

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

Com XML da seguinte forma, SearchForTextOfTag("second") retornaria "text2".

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

Aplica-se a