Thread View: borland.public.cppbuilder.internet.web
4 messages
4 total messages
Started by Peter
Sat, 21 Aug 2004 19:37
TCppWebBrowser doesn't return XML page ?
Author: Peter
Date: Sat, 21 Aug 2004 19:37
Date: Sat, 21 Aug 2004 19:37
67 lines
3163 bytes
3163 bytes
Hi,
In the spirit of "don't invent the wheel a second time" a friend gave me a
piece of code that I'm trying to use but for the purpose I need it it
doesn't seem to work ?
I works 'nicely' for txt or html files with various content but the moment
the first line says : <?xml version="1.0" ?> it doesn't work.
See code further in this post.
1) The moment the downloaded file contains <?xml version="1.0" ?> this line
of code fails :
if(SUCCEEDED(HTMLDocument->QueryInterface(IID_IPersistFile,(LPVOID*)&Persist
File)))
and as you can see this way I cannot save the text to a temp file that
I'm using at the moment (for testing)
Any idea how I can overcome this problem ?
2) The good-working situation worries me as well actually because I seem to
get an "interpreted" result back.
In other words, when downloading a .html file all HTML tags and
decorations are gone ! Only filtered text remains.
When I put the same text in a .txt file for instance I do get the
decorations.
This leaves me a bit uneasy I can't rely on this as there may be
differences between brower version or additonal installations (maybe ??)
I'm also never sure then that when they change something subtile on
server side I get something totally different from TCppWebBroweser than
before ??
What I would like is the FULL and RAW text will all html or xml
decorations
Can this be done and how ??
The code (cut to the essence) :
// ---
bool BrowserStatus;
IHTMLDocument2 *HTMLDocument = NULL;
IPersistFile *PersistFile = NULL;
if (!(!pCppWebBrowser->Busy && pOutputStrings && pCppWebBrowser->Document
&&
String(pCppWebBrowser->LocationURL) != String("about:blank") &&
SUCCEEDED(pCppWebBrowser->Document->QueryInterface(
IID_IHTMLDocument2, (LPVOID*)&HTMLDocument))))
{
BrowserStatus=BROWSER_NOT_READY;
}
else
{
BrowserStatus=BROWSER_DATA_READY;
if(SUCCEEDED(HTMLDocument->QueryInterface(IID_IPersistFile,(LPVOID*)&Persist
File)))
{
// Save the file content to a temporary file
PersistFile->Save(WideString(TempFile),false);
PersistFile->Release();
}
else
{
}
// ---
Re: TCppWebBrowser doesn't return XML page ?
Author: Mark Jacobs
Date: Tue, 24 Aug 2004 15:33
Date: Tue, 24 Aug 2004 15:33
52 lines
2628 bytes
2628 bytes
On Sat, 21 Aug 2004 21:37:41 +0200, Peter <Peter@smart-projects.net> wrote:
> I works 'nicely' for txt or html files with various content but the
> moment
> the first line says : <?xml version="1.0" ?> it doesn't work.
unsigned long mjgeturlconts(AnsiString url,AnsiString fnm)
{
char *bfr; unsigned long nmbyts=0,ba,br=1; FILE *fp;
HINTERNET
hss=InternetOpen("WhateverApp",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
if (!hss) { ShowMessage("Could not Open Internet Session"); return 0;}
HINTERNET hsv=InternetOpenUrl(hss,url.c_str(),NULL,0,0,0);
if (!hsv) { ShowMessage("Could not Open Service "+url);
InternetCloseHandle(hss); return 0;}
InternetQueryDataAvailable(hsv,&ba,0,0);
if (ba==0) { ShowMessage("No Data Available at "+url);
InternetCloseHandle(hss); return 0;}
bfr=(char *)malloc((ba+9)*sizeof(char));
if (!bfr) { ShowMessage("Not Enough Memory - "+AnsiString(ba+9));
InternetCloseHandle(hss); return 0;}
fp=fopen(fnm.c_str(),"wb");
if (!fp) { ShowMessage("Could not Open File "+fnm); free(bfr);
InternetCloseHandle(hss); return 0;}
while (br!=0) { InternetReadFile(hsv,bfr,ba,&br);
fwrite(bfr,sizeof(char),br,fp); nmbyts+=br;}
fclose(fp); InternetCloseHandle(hss); hss=NULL; free(bfr);
return nmbyts;
}
url is the url you are trying to get whatever from, and fnm is the name of
the file you want to store it in.
HTH
--
Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk
markj atty critical dotty co dotty uk
Re: TCppWebBrowser doesn't return XML page ?
Author: Peter
Date: Wed, 25 Aug 2004 09:15
Date: Wed, 25 Aug 2004 09:15
46 lines
2821 bytes
2821 bytes
Thanks
Unfortunately I can't check this out anymore, a trip abroad has been pulled
in, I will check it out in two weeks !
-------------------------------------------------------------
"Mark Jacobs" <markjattycriticaldottycodottyuk> wrote in message
news:opsc8ticwebvaws7@dk-tzx09ucg42z4.s1.sol1.co.uk...
On Sat, 21 Aug 2004 21:37:41 +0200, Peter <Peter@smart-projects.net> wrote:
> I works 'nicely' for txt or html files with various content but the
> moment
> the first line says : <?xml version="1.0" ?> it doesn't work.
unsigned long mjgeturlconts(AnsiString url,AnsiString fnm)
{
char *bfr; unsigned long nmbyts=0,ba,br=1; FILE *fp;
HINTERNET
hss=InternetOpen("WhateverApp",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
if (!hss) { ShowMessage("Could not Open Internet Session"); return 0;}
HINTERNET hsv=InternetOpenUrl(hss,url.c_str(),NULL,0,0,0);
if (!hsv) { ShowMessage("Could not Open Service "+url);
InternetCloseHandle(hss); return 0;}
InternetQueryDataAvailable(hsv,&ba,0,0);
if (ba==0) { ShowMessage("No Data Available at "+url);
InternetCloseHandle(hss); return 0;}
bfr=(char *)malloc((ba+9)*sizeof(char));
if (!bfr) { ShowMessage("Not Enough Memory - "+AnsiString(ba+9));
InternetCloseHandle(hss); return 0;}
fp=fopen(fnm.c_str(),"wb");
if (!fp) { ShowMessage("Could not Open File "+fnm); free(bfr);
InternetCloseHandle(hss); return 0;}
while (br!=0) { InternetReadFile(hsv,bfr,ba,&br);
fwrite(bfr,sizeof(char),br,fp); nmbyts+=br;}
fclose(fp); InternetCloseHandle(hss); hss=NULL; free(bfr);
return nmbyts;
}
url is the url you are trying to get whatever from, and fnm is the name of
the file you want to store it in.
HTH
--
Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk
markj atty critical dotty co dotty uk
Re: TCppWebBrowser doesn't return XML page ?
Author: Peter
Date: Wed, 25 Aug 2004 09:42
Date: Wed, 25 Aug 2004 09:42
58 lines
3234 bytes
3234 bytes
One more thing,
I'm also POSTing data to the url in question !
Can this be done with this code as well ?
-------------------------------------------------------------
"Peter" <Peter@Smart-Projects.net> wrote in message
news:412c5869$1@newsgroups.borland.com...
> Thanks
> Unfortunately I can't check this out anymore, a trip abroad has been
pulled
> in, I will check it out in two weeks !
>
> -------------------------------------------------------------
> "Mark Jacobs" <markjattycriticaldottycodottyuk> wrote in message
> news:opsc8ticwebvaws7@dk-tzx09ucg42z4.s1.sol1.co.uk...
> On Sat, 21 Aug 2004 21:37:41 +0200, Peter <Peter@smart-projects.net>
wrote:
>
> > I works 'nicely' for txt or html files with various content but the
> > moment
> > the first line says : <?xml version="1.0" ?> it doesn't work.
>
> unsigned long mjgeturlconts(AnsiString url,AnsiString fnm)
> {
> char *bfr; unsigned long nmbyts=0,ba,br=1; FILE *fp;
> HINTERNET
> hss=InternetOpen("WhateverApp",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
> if (!hss) { ShowMessage("Could not Open Internet Session"); return 0;}
> HINTERNET hsv=InternetOpenUrl(hss,url.c_str(),NULL,0,0,0);
> if (!hsv) { ShowMessage("Could not Open Service "+url);
> InternetCloseHandle(hss); return 0;}
> InternetQueryDataAvailable(hsv,&ba,0,0);
> if (ba==0) { ShowMessage("No Data Available at "+url);
> InternetCloseHandle(hss); return 0;}
> bfr=(char *)malloc((ba+9)*sizeof(char));
> if (!bfr) { ShowMessage("Not Enough Memory - "+AnsiString(ba+9));
> InternetCloseHandle(hss); return 0;}
> fp=fopen(fnm.c_str(),"wb");
> if (!fp) { ShowMessage("Could not Open File "+fnm); free(bfr);
> InternetCloseHandle(hss); return 0;}
> while (br!=0) { InternetReadFile(hsv,bfr,ba,&br);
> fwrite(bfr,sizeof(char),br,fp); nmbyts+=br;}
> fclose(fp); InternetCloseHandle(hss); hss=NULL; free(bfr);
> return nmbyts;
> }
>
> url is the url you are trying to get whatever from, and fnm is the name of
> the file you want to store it in.
>
> HTH
> --
> Mark Jacobs
> DK Computing
> http://www.dkcomputing.co.uk
> markj atty critical dotty co dotty uk
>
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads