[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

How to retrive values from an HTML table?

I'm looking for a way to populate a listview or grid control with the contents of an HTML table from on of our intranet sites. What can I use to parse HTML tables?
0
deadice
Asked:
deadice
  • 3
  • 2
1 Solution
 
peterchen092700Commented:
The best approach would be using the Document Object Model interface:

Look up the IHtmlDocumentX etc. interfaces. Typically you would:

- acquire the IHtmlDocument somehow (depends on your app)
- Get the IHtmlElement for the Table (depends of the page, best would be giving the table an "id=" attribute)

- QI for IHtmlTable
- IHTmlTable::rows returns an IHtmlElementCollection of the rows, where each element can be QI'd for IHtmlTableRow itf
- IHTmlTableRow returns an IHtmlElementCollection of the rows, where each element can be QI'd for IHtmlTableCell itf

(you can use Colums instead of Rows)

Peter
0
 
deadiceAuthor Commented:
DOM is part of Java, correct? I need a solution in C++ / MFC.
0
 
peterchen092700Commented:
No, the HTML DOM is implemented a COM objects, so you can use it in all MS languages. Just #import <mshtml.dll> and you have everything you need (You could also use "Add From Type Library" in the clazz wizard if you're strictly MFC; but I find the #import - generated classes better)

It might be a bit of a hassle if you are new to COM, but it's definitely easier & more flexible than writing your own parser..

Go to MSDN, and type IHTMLDocument in the index - will give you a starting point.

I would even whip out a sample application - but I don't know if I find the time this weekend.


Peter
0
 
deadiceAuthor Commented:
Ah, I see. Sample code would be nice. Perhaps you have a link?
0
 
deadiceAuthor Commented:
Any further suggestions?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now