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