Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get the HTML source from the WebBrowser Control

How to get the HTML source from the WebBrowser Control

Scheduled Pinned Locked Moved C / C++ / MFC
htmlxmlhelptutorialquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arcrest
    wrote on last edited by
    #1

    Hi everyone. In my application, I use WebBrowser control to send HTTP request and get HTTP response. The response result is the HTML source(am i right?) which can be viewed by clicking View Source in the popup menu. The problem is that the response is not the HTML code , but application-defined data. and I find that the following code works when the response is HTML code,but fails when my application-defined data: IHTMLDocument2 * pDoc = (IHTMLDocument2 *)(m_ie.GetDocument()); BSTR str; IHTMLElement * pElement = NULL; pDoc->get_body(&pElement); pElement->get_outerText(&str); //get_innerText Because sometimes my application data is XML-like format , get_outerText(or inner) will remove the XML tags, that's not what I expect. get_outerHTML(or inner) will add some tags in my application data because there are tags in it. I just want to implement a function that just like "View Source" menu item to get the full actual HTTP response.I use WebBrowser control because it can manage session automatically. Thanks.

    D 1 Reply Last reply
    0
    • A Arcrest

      Hi everyone. In my application, I use WebBrowser control to send HTTP request and get HTTP response. The response result is the HTML source(am i right?) which can be viewed by clicking View Source in the popup menu. The problem is that the response is not the HTML code , but application-defined data. and I find that the following code works when the response is HTML code,but fails when my application-defined data: IHTMLDocument2 * pDoc = (IHTMLDocument2 *)(m_ie.GetDocument()); BSTR str; IHTMLElement * pElement = NULL; pDoc->get_body(&pElement); pElement->get_outerText(&str); //get_innerText Because sometimes my application data is XML-like format , get_outerText(or inner) will remove the XML tags, that's not what I expect. get_outerHTML(or inner) will add some tags in my application data because there are tags in it. I just want to implement a function that just like "View Source" menu item to get the full actual HTTP response.I use WebBrowser control because it can manage session automatically. Thanks.

      D Offline
      D Offline
      Dreamz
      wrote on last edited by
      #2

      eXRange wrote: I just want to implement a function that just like "View Source" menu item Check this[^]...

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups