Re: recursively get links (IHTMLElementCollection)
From: HudsonKane (HudsonKane_at_discussions.microsoft.com)
Date: 08/23/04
- Previous message: HudsonKane: "Re: recursively get links (IHTMLElementCollection)"
- In reply to: HudsonKane: "Re: recursively get links (IHTMLElementCollection)"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 23 Aug 2004 08:39:01 -0700
woot!
with the following I think I am now getting what I am looking for.
Thank you very much for your help
void ListAllLinkUrls(mshtml::HTMLDocument *myDoc)
{
mshtml::IHTMLElementCollection *elementcollection =
dynamic_cast<mshtml::IHTMLElementCollection*>(myDoc->all);
if (elementcollection) {
System::Collections::IEnumerator *ienum =
elementcollection->GetEnumerator();
while (ienum && ienum->MoveNext()) {
mshtml::IHTMLElement *elem=dynamic_cast<mshtml::IHTMLElement
*>(ienum->Current);
if (elem) {
if (elem->tagName->Equals(S"FRAME")) {
mshtml::HTMLFrameBase *fb = dynamic_cast<mshtml::HTMLFrameBase*>(elem);
Interop::SHDocVw::IWebBrowser2
*wb=dynamic_cast<Interop::SHDocVw::IWebBrowser2*>(fb);
if (wb) {
mshtml::HTMLDocument
*myDoc2=dynamic_cast<mshtml::HTMLDocument*>(wb->get_Document());
ListAllLinkUrls(myDoc2);
}
}
else if (elem->tagName->Equals(S"LINK")) {
mshtml::HTMLLinkElement *le =
dynamic_cast<mshtml::HTMLLinkElement*>(elem);
Console::WriteLine("have link {0}",le->href);
}
}
}
}
} // ListAllLinkUrls
"HudsonKane" wrote:
> I see I was using the wrong cast, I am now using
> Interop::SHDocVw::IWebBrowser2
> *wb=dynamic_cast<Interop::SHDocVw::IWebBrowser2*>(elem);
> but wb still is undefined.
> Thank You
>
>
> "HudsonKane" wrote:
>
> > thank you,
> > I now have
> > Interop::SHDocVw::WebBrowser *wb;
> > Should I cast my IHTMLElement to this
> > Interop::SHDocVw::WebBrowser
> > *wb=dynamic_cast<Interop::SHDocVw::WebBrowser*>(elem);
> > and then
> > mshtml::HTMLDocument
> > *myDoc2=dynamic_cast<mshtml::HTMLDocument*>(wb->get_Document());
> > thank you
> >
> > "Igor Tandetnik" wrote:
> >
> > > "HudsonKane" <HudsonKane@discussions.microsoft.com> wrote in message
> > > news:B187FF61-885C-4277-91B2-EFAC096F1E69@microsoft.com
> > > > Thank you for the response. I am very new to both .NET and the
> > > > internet explorer object.
> > > > should the IWebBrowser2 interface be available through mshtml?
> > >
> > > Reference shdocvw.dll
> > >
> > > > can I get it through IHTMLElement?
> > >
> > > I'm not sure what you are asking here.
> > > --
> > > With best wishes,
> > > Igor Tandetnik
> > >
> > > "For every complex problem, there is a solution that is simple, neat,
> > > and wrong." H.L. Mencken
> > >
> > >
> > >
- Previous message: HudsonKane: "Re: recursively get links (IHTMLElementCollection)"
- In reply to: HudsonKane: "Re: recursively get links (IHTMLElementCollection)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|