Click here to Skip to main content
15,900,973 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: What would you recommend for Unmanaged Desktop Apps? Pin
Fabio Franco16-Oct-09 7:42
professionalFabio Franco16-Oct-09 7:42 
GeneralRe: What would you recommend for Unmanaged Desktop Apps? Pin
Rolf Kristensen17-Oct-09 10:19
Rolf Kristensen17-Oct-09 10:19 
GeneralRe: What would you recommend for Unmanaged Desktop Apps? Pin
Fabio Franco18-Oct-09 4:25
professionalFabio Franco18-Oct-09 4:25 
QuestionRegarding Record to MoveFirst,MoveLast and Move Previous. Pin
janaswamy uday15-Oct-09 5:51
janaswamy uday15-Oct-09 5:51 
AnswerRe: Regarding Record to MoveFirst,MoveLast and Move Previous. Pin
David Crow15-Oct-09 6:43
David Crow15-Oct-09 6:43 
AnswerRe: Regarding Record to MoveFirst,MoveLast and Move Previous. Pin
CPallini15-Oct-09 6:46
mveCPallini15-Oct-09 6:46 
GeneralRe: Regarding Record to MoveFirst,MoveLast and Move Previous. Pin
janaswamy uday15-Oct-09 8:08
janaswamy uday15-Oct-09 8:08 
QuestionRe: Regarding Record to MoveFirst,MoveLast and Move Previous. Pin
David Crow15-Oct-09 8:31
David Crow15-Oct-09 8:31 
AnswerRe: Regarding Record to MoveFirst,MoveLast and Move Previous. Pin
Rudheesh15-Oct-09 21:07
Rudheesh15-Oct-09 21:07 
GeneralRe: Regarding Record to MoveFirst,MoveLast and Move Previous. Pin
Rajesh R Subramanian15-Oct-09 8:50
professionalRajesh R Subramanian15-Oct-09 8:50 
GeneralRe: Regarding Record to MoveFirst,MoveLast and Move Previous. Pin
CPallini15-Oct-09 8:55
mveCPallini15-Oct-09 8:55 
QuestionSpinButtonCtrl not working Pin
A&Ms15-Oct-09 4:12
A&Ms15-Oct-09 4:12 
AnswerRe: SpinButtonCtrl not working Pin
Rajesh R Subramanian15-Oct-09 5:24
professionalRajesh R Subramanian15-Oct-09 5:24 
Questionhow to write a display program or a reader program?? Pin
mr bard215-Oct-09 1:50
mr bard215-Oct-09 1:50 
AnswerRe: how to write a display program or a reader program?? Pin
Cedric Moonen15-Oct-09 1:54
Cedric Moonen15-Oct-09 1:54 
GeneralRe: how to write a display program or a reader program?? Pin
mr bard215-Oct-09 2:36
mr bard215-Oct-09 2:36 
GeneralRe: how to write a display program or a reader program?? Pin
Cedric Moonen15-Oct-09 2:45
Cedric Moonen15-Oct-09 2:45 
AnswerRe: how to write a display program or a reader program?? Pin
Richard MacCutchan15-Oct-09 2:09
mveRichard MacCutchan15-Oct-09 2:09 
QuestionRe: how to write a display program or a reader program?? Pin
David Crow15-Oct-09 3:17
David Crow15-Oct-09 3:17 
AnswerRe: how to write a display program or a reader program?? Pin
Rajesh R Subramanian15-Oct-09 3:43
professionalRajesh R Subramanian15-Oct-09 3:43 
QuestionIHTMLDocument2 for Table Par [modified] Pin
NaveenHS15-Oct-09 1:19
NaveenHS15-Oct-09 1:19 
Hello Everyone,


This is my 2nd Post regarding the Text extraction from the WebPages.

In my Previous post David Crow suggested me use IHTMLDocument2 interface,
In the code project depository I found this application

Parsing HTML using MSHTML [] by Philip Patrick ..Extracts all the links in the WebPages Using HREF Tag,

Can I use the same application to extract the Text from the Table from the WebPages ?

I searched for Table tag from which I can extract the text, I did not find any information. Can anyone please tell me is it possible to use MSHTML using IHTMLDocument2 interface can I extract the Text from the <table> Tag.

Thanking you,
Naveen HS.



void CTestDlg::OnBgo() 
{
	UpdateData();
	CWaitCursor wait;
	if(m_csFilename.IsEmpty()){
		AfxMessageBox(_T("Please specify the file to parse"));
		return;
	}
	CFile f;

	//let's open file and read it into CString (u can use any buffer to read though
	if (f.Open(m_csFilename, CFile::modeRead|CFile::shareDenyNone)) {
		m_wndLinksList.ResetContent();
		CString csWholeFile;
		f.Read(csWholeFile.GetBuffer(f.GetLength()), f.GetLength());
		csWholeFile.ReleaseBuffer(f.GetLength());
		f.Close();

		//declare our MSHTML variables and create a document
		MSHTML::IHTMLDocument2Ptr pDoc;
		MSHTML::IHTMLDocument3Ptr pDoc3;
		MSHTML::IHTMLElementCollectionPtr pCollection;
		MSHTML::IHTMLElementPtr pElement;

		HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, 
			IID_IHTMLDocument2, (void**)&pDoc);
		
		//put the code into SAFEARRAY and write it into document
		SAFEARRAY* psa = SafeArrayCreateVector(VT_VARIANT, 0, 1);
		VARIANT *param;
		bstr_t bsData = (LPCTSTR)csWholeFile;
		hr = SafeArrayAccessData(psa, (LPVOID*)&param);
		param->vt = VT_BSTR;
		param->bstrVal = (BSTR)bsData;
		
		hr = pDoc->write(psa);
		hr = pDoc->close();
		
		SafeArrayDestroy(psa);

		//I'll use IHTMLDocument3 to retrieve tags. Note it is available only in IE5+
		//If you don't want to use it, u can just run through all tags in HTML
		//(IHTMLDocument2->all property)
		pDoc3 = pDoc;
		
		//display HREF parameter of every link (A tag) in ListBox
		pCollection = pDoc3->getElementsByTagName(L"A");
		for(long i=0; i<pCollection->length; i++){
			pElement = pCollection->item(i, (long)0);
			if(pElement != NULL){
				//second parameter says that you want to get text inside attribute as is
				m_wndLinksList.AddString((LPCTSTR)bstr_t(pElement->getAttribute("href", 2)));
			}
		}
	}
}


modified on Thursday, October 15, 2009 8:30 AM

AnswerRe: IHTMLDocument2 for Table Par Pin
«_Superman_»15-Oct-09 6:40
professional«_Superman_»15-Oct-09 6:40 
GeneralRe: IHTMLDocument2 for Table Par Pin
NaveenHS16-Oct-09 1:06
NaveenHS16-Oct-09 1:06 
GeneralRe: IHTMLDocument2 for Table Par Pin
«_Superman_»16-Oct-09 5:01
professional«_Superman_»16-Oct-09 5:01 
GeneralRe: IHTMLDocument2 for Table Par Pin
NaveenHS19-Oct-09 1:02
NaveenHS19-Oct-09 1:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.