Share via


SecurityElement.SearchForTextOfTag(String) Metoda

Definice

Vyhledá podřízené objekty podle názvu značky a vrátí text, který obsahuje.

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

Parametry

tag
String

Značka, pro kterou chcete hledat v podřízených elementech.

Návraty

Textový obsah prvního podřízeného elementu se zadanou hodnotou značky.

Výjimky

tag je null.

Příklady

Následující kód ukazuje použití SearchForTextOfTag metody k vyhledání podřízeného objektu podle názvu značky a vrácení obsaženého textu. Tento příklad kódu je součástí většího příkladu SecurityElement pro třídu.

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

Poznámky

Tato metoda odpovídá následujícímu:

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

S následujícím kódem XML SearchForTextOfTag("second") by se vrátil text2.

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

Platí pro