How to get all mshtml.IHTMLDivElement from IHTMLDocument2?

DmitryBoyko picture DmitryBoyko · Feb 10, 2012 · Viewed 10.9k times · Source

How to get all mshtml.IHTMLDivElement from IHTMLDocument2 ?

  private mshtml.IHTMLDocument2 doc = (IHTMLDocument2)WPFBrowser.Document;

  ???

  List<mshtml.IHTMLDivElement> allDivs = ???

Answer

DmitryBoyko picture DmitryBoyko · Feb 10, 2012

I found solution. It works fantastic!

mshtml.IHTMLDocument2 doc = (IHTMLDocument2)MainBrowser.Document;

if (null != doc)
{
     foreach (IHTMLElement element in doc.all)
     {
           if (element.id == "wrapper")
           {
                 HTMLDivElement container = element as HTMLDivElement;

                 dynamic dd = container;

                 string result = dd.IHTMLElement_innerHTML;

                 // You get ANY member of HTMLDivElementClass

                  break;
             }
     }
}