27 Aralık 2015 Pazar

c# get table data webbrowser

HtmlElementCollection tables = wb.document.GetElementsByTagName("table");
try
{
   if (tables.Count <= 0) return;
   HtmlElementCollection rows = tables[0].GetElementsByTagName("tr");
   foreach (HtmlElement row in rows)
   {
    HtmlElementCollection cells = row.GetElementsByTagName("td");
    foreach (HtmlElement cell in cells)
    {
       String text = cell.InnerText;
       if (!String.IsNullOrEmpty(text) && !String.IsNullOrWhiteSpace(text))
       {
       listBox1.Items.Add(text);
       }
     }
   }
}
catch (ArgumentOutOfRangeException exc)
{
   listBox1.Items.Add(exc.Message);
}