如何从IHTMLDocument2获取所有mshtml.IHTMLDivElement?

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

  ???

  List<mshtml.IHTMLDivElement> allDivs = ???

最佳答案

我找到了解决办法。真是太棒了!

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;
             }
     }
}

关于c# - 如何从IHTMLDocument2获取所有mshtml.IHTMLDivElement?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9229980/

10-12 01:25