Share via


SecurityElement.SearchForChildByTag(String) 方法

定義

依它的標記名稱搜尋子項目。

public:
 System::Security::SecurityElement ^ SearchForChildByTag(System::String ^ tag);
public System.Security.SecurityElement? SearchForChildByTag (string tag);
public System.Security.SecurityElement SearchForChildByTag (string tag);
member this.SearchForChildByTag : string -> System.Security.SecurityElement
Public Function SearchForChildByTag (tag As String) As SecurityElement

參數

tag
String

要在子項目中搜尋的標記。

傳回

第一個具有指定標記數值的子 XML 項目,或如果具有 tag 的子項目不存在,則為 null

例外狀況

tag 參數為 null

範例

下列程式代碼示範如何使用 SearchForChildByTag 方法來依其標記名稱尋找子系。 此程式代碼範例是針對 類別提供的較大範例的 SecurityElement 一部分。

if ( localXmlElement->SearchForChildByTag( L"destroytime" ) != nullptr )
if (localXmlElement.SearchForChildByTag("destroytime") != null)
If Not (localXmlElement.SearchForChildByTag("destroytime") Is Nothing) Then

備註

使用 XML, SearchForChildByTag("second") 會傳回子專案 <second>

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

適用於