SecurityElement.SearchForTextOfTag(String) Método

Definição

Localiza um filho pelo seu nome de marca e retorna o texto contido.

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

Parâmetros

tag
String

A marca pela qual pesquisar nos elementos filho.

Retornos

String

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

Exceções

tag é null.

Exemplos

O código a seguir mostra o uso do SearchForTextOfTag método para localizar um filho por seu nome de marca e retornar o texto contido. Este exemplo de código faz parte de um exemplo maior fornecido para a SecurityElement classe.

String^ storedDestroyTime = localXmlElement->SearchForTextOfTag( L"destroytime" );
string storedDestroyTime =
    localXmlElement.SearchForTextOfTag("destroytime");
Dim storedDestroyTime As String = localXmlElement.SearchForTextOfTag("destroytime")

Comentários

Esse método é equivalente ao seguinte:

String^ SearchForTextOfTag(String^ tag)
{
    SecurityElement^ element = this->SearchForChildByTag(tag);
    return element->Text;
}
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 o XML da seguinte maneira, SearchForTextOfTag("second") retornaria "Texto2".

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

Aplica-se a