我正在使用 mshtml 命名空间来访问由 COM 浏览器对象返回的 DOM 元素。
我的代码大致如下
object missing = Type.Missing;
ie.Navigate("http://website.com", ref missing, ref missing, ref missing, ref missing);
mshtml.HTMLDocument theDoc = (mshtml.HTMLDocument)ie.Document;
mshtml.HTMLDivElement myDiv = (mshtml.HTMLDivElement)theDoc.getElementById("divID");
现在,到目前为止,myDiv 是一个 DivElement。
但是,网页本身在“divID”下包含更多的 DIV。也就是说,有很多层嵌套的 DIV。
但是 myDIV 对象的类型是 mshtml.HTMLDivElement,它无法为我提供检索更多 DIVS 作为其子项的功能。
在这种情况下我能做什么?假设我需要以嵌套方式检索更多 DIV?