There is an html like:
<div id="instance" style="color:red;display:block; .... bila bila">
<h2>some text</h2>
</div>
I wanna access style of div via this code;
foreach (HtmlElement link in webBrowser1.Document.GetElementsByTagName("div"))
{
if (link.GetAttribute("id").ToString() == "instance")
{
MessageBox.Show(link.innerhtml);
}
}
But link.innerhtml gives me the inside of div tag, not div's own. Output text of Messag.Box is:
<h2>some text</h2>
I also tried this too:
MessageBox.Show(link.GetAttribute("style"));
but it didnt work.
How to access div properties via same div's id?
You should probably use something like this:
MessageBox.Show(link.OuterHtml);