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

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

반환

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") "텍스트 2"를 반환 합니다.

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

적용 대상