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. help useing Microsoft HTML Object Library in visual c++ 6

help useing Microsoft HTML Object Library in visual c++ 6

Scheduled Pinned Locked Moved C / C++ / MFC
c++phphtmlcom
3 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    method007
    wrote on last edited by
    #1

    Hi all . could any one show me how to use [B]Microsoft HTML Object Library [/B] in visual c++ 6 to extract data from html and populate it in listview. I have done this in visual basic 6 and i posted the code below . I be happy if an expert help me convert it to visual c++ 6 since i need it for a project that has to be done in visual c++ 6. My current visual c++ code retrives html of url and all now i need to be able to do extract the data i wanted from html and populate the listview with that data. I shown a picture of output in the pic.Thanks code that retrives the html for me in visual c++ 6: void CFindUserDlg::OnButton4() { // TODO: Add your control notification handler code here HINTERNET hNet = ::InternetOpen("MSDN SurfBear",PRE_CONFIG_INTERNET_ACCESS,NULL,INTERNET_INVALID_PORT_NUMBER,0) ; HINTERNET hUrlFile = ::InternetOpenUrl(hNet,"http://www.mysite.com/Display.php",NULL,0,INTERNET_FLAG_RELOAD,0) ; char buffer[10*1024] ; DWORD dwBytesRead = 0; BOOL bRead = ::InternetReadFile(hUrlFile,buffer,sizeof(buffer),&dwBytesRead); SetDlgItemText(IDC_EDIT2,buffer); ::InternetCloseHandle(hUrlFile) ; ::InternetCloseHandle(hNet) ; } visual basic 6 code: Private Sub Command3_Click() 'this function places data into listview ' requires that you add a reference to the Microsoft HTML Object Library Dim mydoc As HTMLDocument Dim wombat As IHTMLElementCollection Dim lp As Long Set mydoc = New HTMLDocument 'mydoc.body.innerHTML = "

    " & _ ' " > " & _ ' " " & _ ' " " & _ ' " " & _ ' " Name color tony 33023 cindy 16711935 sarah 3434343 " mydoc.body.innerHTML = RichTextBox1.Text Set wombat = mydoc.getElementsByTagName("TR") ' Get the rows For lp = 1 To wombat.length - 1 ' Ignore first row Set LI = ListView1.ListItems.Add(lp, , wombat.Item(lp).All.Item(0).innerText) ListView1.ListItems(lp).ForeColor = wombat.Item(lp).All.Item(1).innerText LI.ListSubItems.Add , , wombat.Item(lp).All.Item(1).innerText Next End Sub picuture of the output: [IMG]http://i5.photobucket.com/albums/y180/method007/ListViewPop.jpg\[/IMG\]

    N 1 Reply Last reply
    0
    • M method007

      Hi all . could any one show me how to use [B]Microsoft HTML Object Library [/B] in visual c++ 6 to extract data from html and populate it in listview. I have done this in visual basic 6 and i posted the code below . I be happy if an expert help me convert it to visual c++ 6 since i need it for a project that has to be done in visual c++ 6. My current visual c++ code retrives html of url and all now i need to be able to do extract the data i wanted from html and populate the listview with that data. I shown a picture of output in the pic.Thanks code that retrives the html for me in visual c++ 6: void CFindUserDlg::OnButton4() { // TODO: Add your control notification handler code here HINTERNET hNet = ::InternetOpen("MSDN SurfBear",PRE_CONFIG_INTERNET_ACCESS,NULL,INTERNET_INVALID_PORT_NUMBER,0) ; HINTERNET hUrlFile = ::InternetOpenUrl(hNet,"http://www.mysite.com/Display.php",NULL,0,INTERNET_FLAG_RELOAD,0) ; char buffer[10*1024] ; DWORD dwBytesRead = 0; BOOL bRead = ::InternetReadFile(hUrlFile,buffer,sizeof(buffer),&dwBytesRead); SetDlgItemText(IDC_EDIT2,buffer); ::InternetCloseHandle(hUrlFile) ; ::InternetCloseHandle(hNet) ; } visual basic 6 code: Private Sub Command3_Click() 'this function places data into listview ' requires that you add a reference to the Microsoft HTML Object Library Dim mydoc As HTMLDocument Dim wombat As IHTMLElementCollection Dim lp As Long Set mydoc = New HTMLDocument 'mydoc.body.innerHTML = "

      " & _ ' " > " & _ ' " " & _ ' " " & _ ' " " & _ ' " Name color tony 33023 cindy 16711935 sarah 3434343 " mydoc.body.innerHTML = RichTextBox1.Text Set wombat = mydoc.getElementsByTagName("TR") ' Get the rows For lp = 1 To wombat.length - 1 ' Ignore first row Set LI = ListView1.ListItems.Add(lp, , wombat.Item(lp).All.Item(0).innerText) ListView1.ListItems(lp).ForeColor = wombat.Item(lp).All.Item(1).innerText LI.ListSubItems.Add , , wombat.Item(lp).All.Item(1).innerText Next End Sub picuture of the output: [IMG]http://i5.photobucket.com/albums/y180/method007/ListViewPop.jpg\[/IMG\]

      N Offline
      N Offline
      nguyenvhn
      wrote on last edited by
      #2

      Why dont you use Regular Expression to extract data?

      M 1 Reply Last reply
      0
      • N nguyenvhn

        Why dont you use Regular Expression to extract data?

        M Offline
        M Offline
        method007
        wrote on last edited by
        #3

        well i do not know how to use it . could u show me how to extract it using either method and populate the listview.thanks

        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