This article is mainly about WebBrowser control, get the data of table in HTML.
Download a Mshtml.dll First
The main logic is as follows:
Get the object of table
IHTMLDocument2 document = WebBrowser1.Document.DomDocument as IHTMLDocument2;
IHTMLElementCollection tables = (ihtmlelementcollection) document.all.tags ("TABLE");
if (tables.item () = = null)
{
Gets the object according to the name of Franme
HTMLDocument htmldoc = webbrowser1.document;
Htmldoc = webbrowser1.document.window.frames["Frmrpt"]. Document;
String framehtml = webbrowser1.document.window.frames["Frmrpt"]. Document.Body.InnerHtml;
//Get all Franme objects
HTMLDocument doc = (htmldocument) webBrowser1.Document.DomDocument;
Object J;
for (int i = 0; i < doc.parentWindow.frames.length; i++)
{
J = i;
HTMLWindow2 frame = Doc.parentWindow.frames.item (ref j) as HTMLWindow2;
//if (Frame.name = = "Frmrpt")
//{
IHTMLElementCollection tabless = (ihtmlelementcollection) Frame.document.all.tags ("TABLE");
if (tabless.item () = null)
{
foreach (ihtmltable table in tabless)
{
IHTMLElementCollection TTS = TA ble.rows;//because th tag is the table header information that belongs to the table;
foreach (IHTMLElement th in TTS)
{
foreach (IHTMLElement td in Th.children)
{
String ts = td.innerhtml;
}
}
}
//}
}
}
}
Else
{
foreach (ihtmltable table in tables)
{
IHTMLElementCollection TTS = table.rows;//because th tag is the table header information belonging to the table;
foreach (IHTMLElement th in TTS)
{
foreach (IHTMLElement td in Th.children)
{
string ts = td.innerhtml;
}
}
}
}
The WebBrowser control obtains the table data for HTML, including the IFRAME