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 položku pomocí jejího 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 chcete hledat v podřízených prvcích.
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 pro vyhledání podřízeného názvu značky a vrácení obsaženého textu. Tento příklad kódu je součástí většího příkladu, který je k dispozici pro SecurityElement třídu.
String^ storedDestroyTime = localXmlElement->SearchForTextOfTag( L"destroytime" );
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;
}
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
Pomocí XML následujícím způsobem SearchForTextOfTag("second")
vrátí "text2".
<thetag A="123" B="456" C="789"> <first>text1</first>
<second>text2</second></thetag>