Re: Retrieve the DOM of the current web page displayed in firefox

Laurent Mimoun <[email protected]> Fri, 18 Mar 2005 20:13:29 +0100
Newsgroups gmane.comp.mozilla.devel.embedding,gmane.comp.mozilla.devel.xpcom
Message-ID <[email protected]>
> nsCOMPtr<nsIWebBrowser> brow  =3D ... comes e.g. from embedding
> nsCOMPtr<nsIWebNavigation> nav  =3D do_QueryInterface(brow)
>=20
> nsCOMPtr<nsIDOMDocument> doc;
> nav->GetDocument(getter_AddRefs(doc));

Thank you but it does't work. I always have 0x8000ffff failure code.

In fact i get a web browser like this :
	nsCOMPtr<nsIWebBrowser> webBrowser;
	rslt =3D serviceManager->\
		GetServiceByContractID(\
		"@mozilla.org/embedding/browser/nsWebBrowser;1", \
		NS_GET_IID(nsIWebBrowser), \
		getter_AddRefs(webBrowser));=09

is that correct ?=20

After i put the lines
	nsCOMPtr<nsIWebNavigation> nav  =3D do_QueryInterface(webBrowser);

	nsCOMPtr<nsIDOMDocument> doc;
	rslt =3D nav->GetDocument(getter_AddRefs(doc));
	if(NS_FAILED(rslt)) return rslt;

but "doc" is still and always NULL...

I think the problem is how i can get a correct webBrowser object.

someone has an idea of the reason of the problem ?


On Fri, 18 Mar 2005 17:37:39 +0100, Michal Ceresna
<[email protected]> wrote:
> On Friday 18 March 2005 15:33, Laurent Mimoun wrote:
> > Could you please show me how retrieve in C++ the DOM of the current
> > web page displayed in firefox.
>=20
> nsCOMPtr<nsIWebBrowser> brow  =3D ... comes e.g. from embedding
> nsCOMPtr<nsIWebNavigation> nav  =3D do_QueryInterface(brow)
>=20
> nsCOMPtr<nsIDOMDocument> doc;
> nav->GetDocument(getter_AddRefs(doc));
>=20
> best,
> Michal
> --
> Michal Ceresna,
> [email protected]
>=20


--=20
Laurent MIMOUN
Ing=E9nieur JAVA / J2EE - NTIC
Tel : +336 19.67.22.36