Share via


SecurityElement.SearchForTextOfTag(String) 메서드

정의

태그 이름으로 자식을 찾고 포함된 텍스트를 반환합니다.

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

매개 변수

tag
String

자식 요소에서 검색할 태그입니다.

반환

지정된 태그 값을 가지는 첫째 자식 요소의 텍스트 내용입니다.

예외

tag이(가) null인 경우

예제

다음 코드에서는 메서드를 SearchForTextOfTag 사용하여 태그 이름으로 자식을 찾고 포함된 텍스트를 반환하는 방법을 보여줍니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 SecurityElement 클래스입니다.

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

설명

이 메서드는 다음과 같습니다.

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

XML을 SearchForTextOfTag("second") 다음과 같이 사용하면 는 "text2"를 반환합니다.

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

적용 대상