HtmlDocument.GetElementById メソッド
アセンブリ: 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 )
戻り値
指定した値と同じ ID 属性を持つ最初のオブジェクトを返します。


指定した TABLE をドキュメントから取得し、行数を計算して、Web ページに結果を表示するコード例を次に示します。このコード例では、WebBrowser1 という名前のプロジェクト内に WebBrowser コントロールがあり、ID 属性が Table1 の TABLE を使用して 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); }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHtmlDocument.GetElementById メソッドを検索する場合は、下記のリンクをクリックしてください。

- HtmlDocument.GetElementById メソッドのページへのリンク