SecurityElement.SearchForTextOfTag(String) Metodo

Definizione

Trova un elemento figlio in base al nome del tag e restituisce il testo 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 per il quale eseguire la ricerca negli elementi figlio.

Valori restituiti

Contenuto del testo del primo elemento figlio con il valore del tag specificato.

Eccezioni

tag è null.

Esempio

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

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;
}
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 seguito, SearchForTextOfTag("second") restituirebbe "text2".

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

Si applica a