HtmlDocument.GetElementById メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HtmlDocument.GetElementById メソッドの意味・解説 

HtmlDocument.GetElementById メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

要素ID 属性検索キーとして使用して1 つHtmlElement取得します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Function GetElementById ( _
    id As String _
) As HtmlElement
Dim instance As HtmlDocument
Dim id As String
Dim returnValue As HtmlElement

returnValue = instance.GetElementById(id)
public HtmlElement GetElementById (
    string id
)
public:
HtmlElement^ GetElementById (
    String^ id
)
public HtmlElement GetElementById (
    String id
)
public function GetElementById (
    id : String
) : HtmlElement

パラメータ

id

取得する要素ID 属性

戻り値
指定した値と同じ ID 属性を持つ最初オブジェクト返します

解説解説
使用例使用例

指定した TABLEドキュメントから取得し行数計算してWeb ページ結果表示するコード例次に示します。このコード例では、WebBrowser1 という名前のプロジェクト内に WebBrowser コントロールがあり、ID 属性Table1TABLE使用して Web ページ読み込まれている必要があります

Private Function GetTableRowCount(ByVal
 TableID As String) As
 Integer
    Dim Count As Integer
 = 0

    If (WebBrowser1.Document IsNot Nothing)
 Then

        Dim TableElem As HtmlElement = WebBrowser1.Document.GetElementById(TableID)
        If Not (TableElem Is
 Nothing) Then
            For Each RowElem As
 HtmlElement In TableElem.GetElementsByTagName("TR")
                Count = Count + 1
            Next
        Else
            Throw (New ArgumentException("No
 TABLE with an ID of " & TableID & " exists."))
        End If
    End If
    GetTableRowCount = Count
End Function
private Int32 GetTableRowCount(string tableID)
{
    Int32 count = 0;

    if (webBrowser1.Document != null)
    {
        HtmlElement tableElem = webBrowser1.Document.GetElementById(tableID);
        if (tableElem != null)
        {
            foreach (HtmlElement rowElem in
 tableElem.GetElementsByTagName("TR"))
            {
                count++;
            }
        }
        else
        {
            throw(new ArgumentException("No TABLE with an
 ID of " + tableID + " exists."));
        }
    }

    return(count);
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

HtmlDocument.GetElementById メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HtmlDocument.GetElementById メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS