 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Sun Dec 12, 2004 8:31 am Post subject: Problem getting TCppWebBrowser document info |
|
|
I have an application with 2 CppWebBrowsers. A certain website creates
an XML document that opens in a new window, and I want to get at the
XML document source to parse.
The XML Document looks like:
<?xml version="1.0" encoding="UTF-8"?>
<LabReport>
<ReportHeader>
<Requested-By></Requested-By>
<Requested-On>12/11/2004 07:22 PM</Requested-On>
</ReportHeader>
<Clinic AccountNumber="XXXXX" Ext-ID="XXXXX" Status="Active">
<Name>University Vet Hospital</Name>
<Address>
....
ie not something describing a web page at all...
I've snagged a couple of code snippets to get the CppWebBrowser
document info, which work - for html documents loaded into either
CppWebBrowser. However, when I try getting the XML data, I tend to get
giberish "ÿþ<".
The current code is (though I've tried a few others from various
groups, ComInterface for a slicker transfer via streams, to saving to a
temp file, those don't work for the XML file either):
Memo1->Lines->Clear();
IHTMLDocument2 *htm = NULL;
if(CppWebBrowser2->Document &&
SUCCEEDED(CppWebBrowser2->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&htm))){
IPersistStreamInit *spPsi = NULL;
if(SUCCEEDED(htm->QueryInterface(IID_IPersistStreamInit,
(LPVOID*)&spPsi)) && spPsi){
IStream *spStream = NULL;
OleCheck(CreateStreamOnHGlobal(NULL, true, &spStream));
if(spStream)
{
__int64 nSize = 0;
STATSTG ss;
LARGE_INTEGER nMove;
nMove.QuadPart = 0;
OleCheck(spPsi->Save(spStream, true));
OleCheck(spStream->Seek(nMove, STREAM_SEEK_SET,
(ULARGE_INTEGER*)&nSize));
OleCheck(spStream->Stat(&ss, STATFLAG_NONAME));
nSize = ss.cbSize.QuadPart;
String TempString;
TempString.SetLength(nSize);
OleCheck(spStream->Read((void *)TempString.data(),
nSize, NULL));
Memo1->Text = String(TempString);
OleCheck(spStream->Release()); }
spPsi->Release();
}
htm->Release();
} |
|
| Back to top |
|
 |
Guest
|
Posted: Mon Dec 13, 2004 1:57 pm Post subject: Re: Problem getting TCppWebBrowser document info |
|
|
Addendum:
The codes are transfering data from the wrong CppWebBrowser.
I tried this instead:
Memo1->Lines->Clear();
IHTMLDocument2 *htm = NULL;
if(CppWebBrowser2->Document &&
SUCCEEDED(CppWebBrowser2->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&htm)))
{
htm->execCommand(WideString("SelectAll"), VARIANT_FALSE,
(Variant)("c:\\temp.html"), NULL );
}
This brings up a save file as dialog box, the saved file looks like
this:
"ÿþ< H T M L > < H E A D >
<S T YL E >"
Except that the spaces are, ummm.... CppBuilder shows boxes, most
editors (including this browser) aren't showing the characters or
anything inbetween them... Which means data has been transfered to the
TMemo, it just can't handle these characters. But reading through the
code, this is the source code from CppWebBrowser1, not CppWebBrowser2.
So with two CppWebBrowsers, how do I grab the source from the second?
Or..... Can I force it to load into the same window?
//---------------------------------------------------------------------------
void __fastcall TForm1::CppWebBrowser1NewWindow2(TObject *Sender,
LPDISPATCH *ppDisp, TOLEBOOL *Cancel)
{
*ppDisp = CppWebBrowser1->Application;
}
This simply doesn't load the new page. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|