Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Wed, 22 Jun 2005 10:03:00 -0700,    group: microsoft.public.inetsdk.programming.html_objmodel        back       


Iterating HTML Tables and Table Elements From VB.NET   
I have an HTML document that contains numerous one-cell tables, each
containing the name of a file.

Is it possible to open an HTML document from VB.NET and iterate the tables
and elements wthin the tables in order to get to the text within the cells?
I'm trying to use the MSHTML DLL and seems likely that it has the
capability, but I haven't figured out how to do it yet.  The
mshtml.HTMLDocument doesn't provide a Tables collection.
date: Wed, 22 Jun 2005 10:03:00 -0700   author:   Phil Galey am

RE: Iterating HTML Tables and Table Elements From VB.NET   
Even though there is not a Tables collection per se, you can create a 
functional one with getElementsByTagName("table")

What follow is not VB, but is written in a scripting language called 
AutoIt... you should be able to readily adapt it however.

Dale

$ObjIE=ObjCreate("InternetExplorer.Application")
With $ObjIE
  .Visible = True
  .Navigate("http://www.autoitscript.com/")

  while .ReadyState <> 4
    Sleep(50)
  wend
EndWith

$document = $objIE.document
$body = $document.getElementsByTagName("body").item(0)
$tables = $body.getElementsByTagName("table")

For $table in $tables
	$rows = $table.getElementsByTagName("tr")
	For $row in $rows
		$tds = $row.getElementsByTagName("td")
		For $td in $tds
			; Display the HTML contents of each cell...
			ConsoleWrite($td.innerText)
		Next
	Next
Next

Exit

"Phil Galey" wrote:

> I have an HTML document that contains numerous one-cell tables, each
> containing the name of a file.
> 
> Is it possible to open an HTML document from VB.NET and iterate the tables
> and elements wthin the tables in order to get to the text within the cells?
> I'm trying to use the MSHTML DLL and seems likely that it has the
> capability, but I haven't figured out how to do it yet.  The
> mshtml.HTMLDocument doesn't provide a Tables collection.
> 
> 
>
date: Wed, 20 Jul 2005 06:37:05 -0700   author:   DaleH

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us