Sam Hobbs

Sam Hobbs

  • 52
  • 29.3k
  • 2.1m

IE 9 IDOMNodeIterator interface

Sep 12 2011 5:07 AM
IE 9 has the IDOMNodeIterator interface to iterate text nodes. I am trying to use it in C# but I cannot. Ideally someone can figure out why not but if someone can duplicate the problems I have encountered then it will help me to know that I am not overlooking something. I have a reference for mshtml.tlb. The Object Browser shows that IDOMNodeIterator is in the mshtml namespace but the compiler does not see it; Intellisense does not see it and I get compile errors when I try to compile. The following shows one way I have tried but I have tried many other possibilities.

int ulWhatToShow = 0;
mshtml.IHTMLDocument2 Document = new mshtml.HTMLDocumentClass();
//
// I load the document here
//
//mshtml.IDOMNodeIterator = ((mshtmlv9.IDocumentTraversal)Document).createNodeIterator(Document.body, ulWhatToShow, null, false);
mshtml.IDOMNodeIterator = ((mshtml.HTMLDocumentClass)Document).createNodeIterator(Document.body, ulWhatToShow, null, false);

I sure don't understand why the IDE and the compiler do not see IDOMNodeIterator when the Object Browser does. The compiler says that IDOMNodeIterator is not in the namespace and Intellisense indicates that also. Does that happen to you too?
There are a couple of ways to iterate text nodes in IE versions prior to 9 but I want to be able to use the IE 9 IDOMNodeIterator interface if possible.

Answers (4)