Assume that your table structure is like this
<table id="Table4">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</table>
then you will have to code as below to assign the values to the respective text box, i would recommend you to use
break point[
^] and
debugger [
^]to play around with the
object
and
properties
getting in the loop, based on that you can customize your code which suits your need.
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
HtmlElement table = webBrowser1.Document.GetElementById("table4");
var rows = table.GetElementsByTagName("tr");
foreach (HtmlElement row in rows)
{ int i = 0;
foreach (HtmlElement cell in row.GetElementsByTagName("td"))
{
i++;
string value = cell.InnerText;
if (i == 1)
textBox1.Text = value;
if (i == 2)
textBox2.Text = value;
if (i == 3)
textBox3.Text = value;
if (i == 4)
textBox4.Text = value;
}
}
}
Since you knew the Id of the table, you can get the Table Element by using
GetElementById
instead of
TagName