SecurityElement.SearchForTextOfTag(String) Metodo

Definizione

Trova un elemento figlio in base al nome del tag e restituisce il testo in esso contenuto.

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

Parametri

tag
String

Tag da cercare negli elementi figlio.

Restituisce

String

Contenuto testuale del primo elemento figlio con il valore di tag specificato.

Eccezioni

tag è null.

Esempio

Il codice seguente illustra l'uso del metodo per trovare un elemento figlio in base al nome SearchForTextOfTag del tag e restituire il testo contenuto. Questo esempio di codice fa parte di un esempio più esaustivo fornito per la SecurityElement classe .

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

Commenti

Questo metodo equivale al seguente:

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

Con XML come indicato di SearchForTextOfTag("second") seguito, restituirebbe "text2".

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

Si applica a