I have done this and successfully got the Title and the URL of the html
page:
////////////////////////////////////////////////////////////////////
nsCOMPtr<nsIDOMWindow> window;
nsresult rv =
aWebProgress->GetDOMWindow(getter_AddRefs(window));
if(window)
{
nsCOMPtr<nsIDOMDocument> domDoc;
rv =
window->GetDocument(getter_AddRefs(domDoc));
if(domDoc)
{
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc =
do_QueryInterface(domDoc);
if(htmlDoc)
{
nsEmbedString strDocText;
htmlDoc->GetTitle(strDocText);
const PRUnichar *strTitle =
strDocText.get();
htmlDoc->GetURL(strDocText);
const PRUnichar *strURL =
strDocText.get();
//how to get the HTML
page source??
}
}
}
///////////////////////////////////////
But after looking into the nsIDOMHTMLDocument.h, I can not find
something useful other than GetBody(nsIDOMHTMLElement**). I thought
this returns the content inside the <body> tag in the HTML page but I
can't find something as useful as get_innerHTML /get_innerBody as in
Internet Explorer. What is the way to retrieve the HTML page source
after I get the valid htmlDOC? please advice.
Also I found something off the group that is supposed to be able to
retrieve the HTML page source as string:
--- Snippet ---
nsresult rv;
PRUnichar *serial;
nsCOMPtr<nsIDOMSerializer>
serializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rv));
if (NS_FAILED(rv)) return;
nsCOMPtr<nsIDOMDocument> domDoc;
mWebNav->GetDocument(getter_AddRefs(domDoc));
rv = serializer->SerializeToString(domDoc, &serial);
--- Snippet --
but I can find no nsIDOMSerializer.h in either gecko-sdk(1.7) / mozilla
source (1.5.04) so I can't use it.
Where I can find nsIDOMSerializer.h? Please advice.
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom