SecurityElement.SearchForTextOfTag(String) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Vyhledá podřízenou hodnotu podle názvu značky a vrátí obsažený text.
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 se má hledat v podřízených elementech.
Návraty
Textový obsah prvního podřízeného prvku 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 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 uvedeného pro třídu SecurityElement.
string storedDestroyTime =
localXmlElement.SearchForTextOfTag("destroytime");
Dim storedDestroyTime As String = localXmlElement.SearchForTextOfTag("destroytime")
Poznámky
Tato metoda je ekvivalentní následujícímu:
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
Následující kód XML SearchForTextOfTag("second") vrátí text "text2".
<thetag A="123" B="456" C="789"> <first>text1</first>
<second>text2</second></thetag>