I can get the serialized HTML from the top HTML dom node but that is
not the original HTML. This means that the following code does NOT
quite do the trick although it gets close.
nsCOMPtr<nsIDOMSerializer> pSerializer =
do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rv);
if (NS_FAILED(rv))
return VR_ERROR;
nsCOMPtr<nsIDOMDocument> pDOMDocument;
pDOMWindow->GetDocument(getter_AddRefs(pDOMDocument));
if (!pDOMDocument)
return VR_ERROR;
nsEmbedString nsTagName(L"html");
nsCOMPtr<nsIDOMNodeList> pDOMNodeList;
rv = pDOMDocument->GetElementsByTagName(nsTagName,
getter_AddRefs(pDOMNodeList));
if (!pDOMNodeList)
return VR_ERROR;
unsigned int nCount = 0;
pDOMNodeList->GetLength(&nCount);
if (nCount == 0)
return VR_ERROR;
nsCOMPtr<nsIDOMNode> pDOMNode;
pDOMNodeList->Item(0, getter_AddRefs(pDOMNode));
nsEmbedString nsHtml;
pSerializer->SerializeToString(pDOMNode, nsHtml);
Internet Explorer DOES provides this capability using the
IPersistStreamInit interface
CComQIPtr<IPersistStreamInit> spStreamInit(pDocument2);
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD, 0);
CComPtr<IStream> spStream;
CreateStreamOnHGlobal(hMem, TRUE, &spStream);
spStreamInit->Save(spStream, FALSE);
LPSTR szHtml = (LPSTR)GlobalLock(hMem);
Does anybody know of a way to get the original HTML loaded by Firefox.
Thanks in advance,
-Pascal