I am attempting to extract some data from various tables in a web page. I've decided to use the WebBrowser control and DOM to get to the data. I'm struggling with the correct data types to use to access of the results of the DOM methods.
The following code snippet is intended to simply print the number of tables on a web page, and then the size of each table. The first print works, but none of the following do (the exception get's thrown).
I believe the problem is that objTable is simply an object, not a collection of objects.
VB Code:
Private Sub DumpTables() Dim x As Integer Dim i, j, k As Integer Dim s As String Dim objTable As Object Dim ObjDoc As Object ' wbrBrowser is the WebBrowser Control on the main form. ObjDoc = wbrBrowser.Document Try objTable = wbrBrowser.Document.getElementsByTagName("TABLE") x = objTable.length Debug.WriteLine("Number of Tables " & x) For i = 0 To x - 1 j = objTable(0).length Debug.WriteLine("Table: all: " & j _ & " Rows: " & objTable(i).rows.length _ & " Cols: " & objTable(i).cols) Next Catch ex As Exception MessageBox.Show("It is likely that your submit does not exist or has no name attribute. Check the HTML source.", "No name att. or no submit available", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End Try End Sub
Here is a link to the MSDN document that describes the DOM.
It seems like I'm very close to understanding this, but can't figure out what types to use so VB can interpret the results from the DOM calls.
Any pointers or ideas would be appreciated.




Reply With Quote