J
John Williams
I have a HTML page consisting of several tables at the top level of the DOM,
interpersed with other HTML tags. For example:
HTML
BODY
-- SCRIPT
-- SCRIPT
-- #comment
-- SCRIPT
-- A
-- TABLE
-- TABLE
-- TABLE
-- NOSCRIPT
-- #comment
-- BR
-- TABLE
-- #comment
-- #comment
What's the best way of accessing the last table at the top level (i.e. the
last table in the immediate children of HTMLdocument.body)? I'm currently
using the technique shown by the following code snippet, but is there an
easier way?
(ByVal mDoc As mshtml.HTMLDocument)
Dim mElems As mshtml.IHTMLElementCollection
Dim mElem As mshtml.IHTMLElement
Dim mTable As mshtml.IHTMLTable
Dim i As Integer
mElems = mDoc.body.children
For i = mElems.length - 1 To 0 Step -1
mElem = mElems.item(i)
If TypeOf mElem Is mshtml.HTMLTableClass Then
mTable = mElem 'the required table - break out here
End If
Next
Any help or info is much appreciated.
interpersed with other HTML tags. For example:
HTML
BODY
-- SCRIPT
-- SCRIPT
-- #comment
-- SCRIPT
-- A
-- TABLE
-- TABLE
-- TABLE
-- NOSCRIPT
-- #comment
-- BR
-- TABLE
-- #comment
-- #comment
What's the best way of accessing the last table at the top level (i.e. the
last table in the immediate children of HTMLdocument.body)? I'm currently
using the technique shown by the following code snippet, but is there an
easier way?
(ByVal mDoc As mshtml.HTMLDocument)
Dim mElems As mshtml.IHTMLElementCollection
Dim mElem As mshtml.IHTMLElement
Dim mTable As mshtml.IHTMLTable
Dim i As Integer
mElems = mDoc.body.children
For i = mElems.length - 1 To 0 Step -1
mElem = mElems.item(i)
If TypeOf mElem Is mshtml.HTMLTableClass Then
mTable = mElem 'the required table - break out here
End If
Next
Any help or info is much appreciated.