473,657 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AxWebBrowser & HTML Code

Hello Newsgroup,

I have a simple question I think, but after a long time searching, get
no answer.
I want to get the original html source code from a page loaded in the
AxWebBrowser Control.

At the Moment i use this code:

IHTMLDocument3 htmlDoc3 = new HTMLDocumentCla ss();
htmlDoc3 = (IHTMLDocument3 ) browser01.Docum ent;
String inHTML = htmlDoc3.docume ntElement.inner HTML.ToString() ;

But the HTML code in inHTML is not the original source code.
It seems to be parsed and analysed HTML without quots and other thinks
that look bad.

It can't be that there ist no other method to get the original source
code of a web page.

Can somebody help me?

Regards Nabor
Nov 16 '05 #1
8 4784
You do not have to go so far to get HTML of a webpage, use HTTPWebRequest
and there are other ways to do the same thing.
"Nabor Gilgalad" <na************ @gmx.de> wrote in message
news:eD******** ******@TK2MSFTN GP12.phx.gbl...
Hello Newsgroup,

I have a simple question I think, but after a long time searching, get no
answer.
I want to get the original html source code from a page loaded in the
AxWebBrowser Control.

At the Moment i use this code:

IHTMLDocument3 htmlDoc3 = new HTMLDocumentCla ss();
htmlDoc3 = (IHTMLDocument3 ) browser01.Docum ent;
String inHTML = htmlDoc3.docume ntElement.inner HTML.ToString() ;

But the HTML code in inHTML is not the original source code.
It seems to be parsed and analysed HTML without quots and other thinks
that look bad.

It can't be that there ist no other method to get the original source code
of a web page.

Can somebody help me?

Regards Nabor

Nov 16 '05 #2
Where can I get the HTTPWebRequest from the AxWebBroser?
If this is not possible and I have to request a page twice, first for
the browser controle an then to get the source code, this is not a
solution for me.
I have to display a web page in the browser control and I can't request
the same page a second time.
Please explain a little more detailed how do you think this would work.

Regards Nabor

Ashish Das schrieb:
You do not have to go so far to get HTML of a webpage, use HTTPWebRequest
and there are other ways to do the same thing.


Nov 16 '05 #3
I have researched this question very extensively, and I'm confident
that it is impossible to get the original, unparsed HTML code out of
the AxWebBrowser control.

I think that your best solution may be to acquire the HTML via an
HTTPWebRequest -- which will give you the raw HTML -- and then feed the
HTML to the web browser control by assigning it to
IHTMLDocument2. body.outerHTML.

Nov 16 '05 #4
Realy... thats not good...
Does this mean that I have to rebuild the functionality for get and post
request?
Because, when I click on in link in the browser control i have to get
the next page by HTTPWebRequest and not just with the browser control... :(

Regards Nabor

Adam schrieb:
I have researched this question very extensively, and I'm confident
that it is impossible to get the original, unparsed HTML code out of
the AxWebBrowser control.

I think that your best solution may be to acquire the HTML via an
HTTPWebRequest -- which will give you the raw HTML -- and then feed the
HTML to the web browser control by assigning it to
IHTMLDocument2. body.outerHTML.

Nov 16 '05 #5
WRH
Hello
Here's a snippet of C++ code I use that may help
if C# .NET has equivalent methods...

(Init m_Doc first)
IHTMLElement *m_Element, *m_ParElement
IHTMLDocument2 *m_Doc

CString CMfcieView::Get Source()
{
CString src;
BSTR bstr;

HRESULT res;

if(m_Doc == NULL)return "Error";

try
{
res = m_Doc->get_body(&m_El ement);

if(res != S_OK)return "Error";

res = m_Element->get_parentElem ent(&m_ParEleme nt);

if(res != S_OK)return "Error";

res = m_ParElement->get_outerHTML( &bstr);
if(res != S_OK)return "Error";
}
catch (...)
{
return "Error";
}

bstr_t tmpbstr(bstr, FALSE);

src = (LPCTSTR)tmpbst r;

return src;
}

"Nabor Gilgalad" <na************ @gmx.de> wrote in message
news:eD******** ******@TK2MSFTN GP12.phx.gbl...
Hello Newsgroup,

I have a simple question I think, but after a long time searching, get no
answer.
I want to get the original html source code from a page loaded in the
AxWebBrowser Control.

At the Moment i use this code:

IHTMLDocument3 htmlDoc3 = new HTMLDocumentCla ss();
htmlDoc3 = (IHTMLDocument3 ) browser01.Docum ent;
String inHTML = htmlDoc3.docume ntElement.inner HTML.ToString() ;

But the HTML code in inHTML is not the original source code.
It seems to be parsed and analysed HTML without quots and other thinks
that look bad.

It can't be that there ist no other method to get the original source code
of a web page.

Can somebody help me?

Regards Nabor

Nov 16 '05 #6
Hello,

I'm not that good in C++.
Have a look to my comments.

WRH schrieb:
Hello
Here's a snippet of C++ code I use that may help
if C# .NET has equivalent methods...

(Init m_Doc first)
IHTMLElement *m_Element, *m_ParElement
IHTMLDocument2 *m_Doc

CString CMfcieView::Get Source()
{
CString src;
BSTR bstr;

HRESULT res;

if(m_Doc == NULL)return "Error";

try
{
res = m_Doc->get_body(&m_El ement);

if(res != S_OK)return "Error";

res = m_Element->get_parentElem ent(&m_ParEleme nt);

if(res != S_OK)return "Error";

res = m_ParElement->get_outerHTML( &bstr);
if(res != S_OK)return "Error";
}
catch (...)
{
return "Error";
}

Until here I'm with you. I've got the value outerHTML.
This value is not the original source code so far.
And what comes next?
What did you do here?
bstr_t tmpbstr(bstr, FALSE);

src = (LPCTSTR)tmpbst r;

return src;
}


Nov 16 '05 #7
In the browser control there is a context menu where I get the original
source code. Why should this function not be available via C#?
Nov 16 '05 #8
WRH

"Nabor Gilgalad" <na************ @gmx.de> wrote in message
news:uG******** ******@tk2msftn gp13.phx.gbl...
Hello,

I'm not that good in C++.
Have a look to my comments.

WRH schrieb:
Hello
Here's a snippet of C++ code I use that may help
if C# .NET has equivalent methods...

(Init m_Doc first)
IHTMLElement *m_Element, *m_ParElement
IHTMLDocument2 *m_Doc

CString CMfcieView::Get Source()
{
CString src;
BSTR bstr;

HRESULT res;

if(m_Doc == NULL)return "Error";

try
{
res = m_Doc->get_body(&m_El ement);

if(res != S_OK)return "Error";

res = m_Element->get_parentElem ent(&m_ParEleme nt);

if(res != S_OK)return "Error";

res = m_ParElement->get_outerHTML( &bstr);
if(res != S_OK)return "Error";
}
catch (...)
{
return "Error";
}


Until here I'm with you. I've got the value outerHTML.
This value is not the original source code so far.
And what comes next?
What did you do here?
bstr_t tmpbstr(bstr, FALSE);

src = (LPCTSTR)tmpbst r;

return src;
This just converts a C++ BSTR type (a string with a length
specifier which may contain nulls) to a C++ CString type,
equiv to a C# string

Heres the BSTR definition..

.... BSTRs, which are length-prefixed strings. The length is stored as an
integer at the memory location preceding the data in the string.
A BSTR is null-terminated after the last counted character but may also
contain null characters embedded within the string. The string length is
determined by the character count, not the first null character.
Does C# .NET specify the argument type for get_outerHTML ...
perhaps its not a BSTR...


}

Nov 16 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3779
by: Martin Ho | last post by:
Hey Everyone, I really hope there is someone who can figure out this problem. Honestly, I spent 3 days now trying to find the solution, but nothing works. I'll try to explain the problem shortly, so I don't take too much of your time. Problem:
3
2966
by: Michael C | last post by:
Hi all, Quick question about the AxSHDocVw.AxWebBrowser Component. I was wondering if there is a way to view pages generated internally within my application without writing them to disk. For instance, I'd like to do something like the following: string page = "<HTML><BODY>This is a test.</BODY></HTML>"; And display the page variable's contents in the AxWebBrowser (without
1
1125
by: TimSLC | last post by:
Hi there, Ok if anyopne has been reading my past posts I have been looking for something in C# that will allow me access to the HTML DOM and visually display in real time any changes my program makes to a web page (this is all for testing purposes of a large enterprise web app). Anywho, I think axWebBrower is going to work. I have 4 simple questions: 1) Is the axWebBrowser managed code?
9
2733
by: Djavdet | last post by:
Hi everyone, I need to work with web sites from my program but i don't need to show web site content.. I only need to get web page change something in html document and either move on or send something back.. Basically pretty much the same what usually people would do with IE but no windows... I thought that it would be easier to implement using AxWebBrowser ActiveX control, but I can't figure out how to set that OCXState field if I...
3
2570
by: MeNotHome | last post by:
I have been trying to find all the properties and methods documentation on the axwebbrowser control. For example a list of follwing and their results axwebbrowser.document.body.outerhtml axwebbrowser.document.body.innerhtml etc etc. thx
0
2046
by: sagar.jawale | last post by:
Hi, In my c# windows application, i am using AxSHDocVw.AxWebBrowser. I am displaying a generated receipt html in this browser. Also, for printing the same html, i am using the following command : axWebBrowser2.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,ref empty,ref empty);
6
3762
by: Dave Booker | last post by:
It appears that I cannot correctly install the AxWebBrowser in VS2005. I can instantiate an "AxWebBrowser browser" and refer to its members, properties, and methods. I'm having trouble with the AxWebBrowser.Document: When I print browser.Document.GetType().ToString() at runtime, I get "mshtml.HTMLDocumentClass". But The VS2005 compiler does not recognize the member AxWebBrowser.Document as anything other than a System.Object -- e.g.,...
2
3044
by: Vicente García | last post by:
hello all, Sorry for my English. I am making up an application and I must show a web. The web contains a power point but I have a problem because I type something like: AxWebBrowser.Navigate(URL) but with the power point also is showed a vertical scroll bar, and I wish don't show that scroll. May anyone please tell me how I can do that? Thanks in advance, Vicente.
2
2112
by: Michael | last post by:
Hi experts, I am using axWebBrowser in windows form to load web pages. There is a page that contains a group of buttons. (More than 10 buttons.) The source code behind each button is like below: <input type="submit" name="Submit" value="Submit" onClick="afm.__act.value=' SITE.9.20081206A__id.30.AdminsSelected.adp.actRegister';return SubmitOnlyOnce();">
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.