BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem getting TCppWebBrowser document info

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet)
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Sun Dec 12, 2004 8:31 am    Post subject: Problem getting TCppWebBrowser document info Reply with quote



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






PostPosted: Mon Dec 13, 2004 1:57 pm    Post subject: Re: Problem getting TCppWebBrowser document info Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.