Alex Rest
January 15th, 2004, 03:34 PM
I want to convert HTML to TEXT from some string
It good works in VB code like this:
Dim body As String
Dim hd As HTMLDocument
Dim str As String
Set hd = New HTMLDocument
Open "c:\test\a.html" For Input As #1
body = Input(4188, #1)
hd.body.innerHTML = body
Debug.Print hd.body.outerText
I try do it with VC++ so:
IHTMLDocument2 *pHtmlDoc = NULL;
HRESULT hr;
hr = CoCreateInstance(CLSID_HTMLDocument,
NULL,
CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2,
(LPVOID *) &pHtmlDoc);
IHTMLElement *pBody;
hr = pHtmlDoc->createElement(CComBSTR("BODY"), &pBody);
CComBSTR bsText;
hr = pBody->get_outerHTML(&bsText); // OK, we have "<BODY></BODY>"
CComBSTR SomeText("<BODY><b>Some Text</b></BODY>);
:mad: hr = pBody->put_outerHTML((BSTR)SomeText);
It falls down while "put_outerHTML"
Who know right solution?
PS
Set hd = New HTMLDocument
creates an object with html code with base document structure (5 tags: html, body, head, title, p).
CoCreateInstance creates absolutely empty object.
Why?
Thanks,
Alex
It good works in VB code like this:
Dim body As String
Dim hd As HTMLDocument
Dim str As String
Set hd = New HTMLDocument
Open "c:\test\a.html" For Input As #1
body = Input(4188, #1)
hd.body.innerHTML = body
Debug.Print hd.body.outerText
I try do it with VC++ so:
IHTMLDocument2 *pHtmlDoc = NULL;
HRESULT hr;
hr = CoCreateInstance(CLSID_HTMLDocument,
NULL,
CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2,
(LPVOID *) &pHtmlDoc);
IHTMLElement *pBody;
hr = pHtmlDoc->createElement(CComBSTR("BODY"), &pBody);
CComBSTR bsText;
hr = pBody->get_outerHTML(&bsText); // OK, we have "<BODY></BODY>"
CComBSTR SomeText("<BODY><b>Some Text</b></BODY>);
:mad: hr = pBody->put_outerHTML((BSTR)SomeText);
It falls down while "put_outerHTML"
Who know right solution?
PS
Set hd = New HTMLDocument
creates an object with html code with base document structure (5 tags: html, body, head, title, p).
CoCreateInstance creates absolutely empty object.
Why?
Thanks,
Alex