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);
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.

CharlesPosted Sep 21, 2011, 4:04 AM
Also, you can use the .idl file to create a .tlb file, but you can skip this step since you already have it. Sometimes the .tlb file is not provided.
Sam HobbsPosted Sep 21, 2011, 2:32 PM
You should write an article for this web site about the need for and the procedure for creating a reference for IE 9. I know it will be appreciated.
Sam HobbsPosted Sep 20, 2011, 5:21 PM
Do you know why the interop for mshtml v9 is not provided? What says that it is not?
The mshtml.dll file in my C:\Windows\System32 have a file and product version of 9.0.8112.16434; does that mean that it is for IE 9?
Can you explain why the Object Browser shows IDOMNodeIterator but the compiler does not see it?
Note that in the code I posted here, I left in some commented code. I did not realize that part of the commented code has mshtmlv9 instead of mshtml. It has mshtmlv9 because I have already created a mshtmlv9.dll using:
I referenced that DLL and used the namespace mshtmlv9 in my code but I was unable to get the program to compile.
Note that in the thread that you referenced, it says "the mshtml.tlb file should be in C:\Windows\System32 and/or C:\Windows\SysWOW64 after installing IE9". I see no explanation for why the DLL is not for IE9 if it is not. The MSDN forum thread refers to the Stackoverflow thread asking how to compile the idl. It is my understanding that we do not need to compile the idl; that the type library is already provided. Microsft certainly did not suggest that I compile the idl; see MSHTML.IDOMNodeIterator.
Have you been successful at getting IDOMNodeIterator to work? If so then I will do everything I can to use your help. Otherwise the thing I am asking for is for someone to attempt to do it and then simply duplicate the problem.
Also, Yi Feng Li of Microsoft and you are saying to create a mshtml.dll file from the tlb. Yet when I try to add a reference for the C:\Windows\System32\mshtml.dll file, that does not work. I am using the tlb file, so I don't understand how it would make any difference if I generate a dll from the tlb file.
CharlesPosted Sep 20, 2011, 2:56 PM
tlbimp mshtml.tlb /out:Microsoft.mshtml.dll /namespace:mshtml /asmversion:9.0
The mshtml.tlb file should be in C:\Windows\System32 and/or C:\Windows\SysWOW64 after installing IE9.
See the following for details:
http://social.msdn.microsoft.com/Forums/en-US/clr/thread/b6512b8d-e53e-4959-a917-0cae731827b2/#2ff37862-ccb1-4f57-bc58-646daf4953ce