Posts: 37
Threads: 17
Joined: Mar 2005
If I use:
Htm el=htm("BODY" "" "" "Internet Explorer" "2/3" 0 0x20)
all=el.DocText
I can see all of the data of the table, but the columns are running together. Is there a way to read each cell of the table?
For example: if the table looks like this
A B C
D E F
running the above gives me
ABC
DEF
I just want to see
A
D
Hope this sort of makes sense.
Thanks for the help (again).
Posts: 37
Threads: 17
Joined: Mar 2005
I found a way to do this, but there may be a better way. Here is what I am doing:
Htm el=htm("BODY" "" "" "Internet Explorer" "2/3" 0 0x20)
all=el.HTML
spe 200
int x
int counter=1
str what
str ggg
str hhh
foreach qqq all
if(!qqq.len) continue
if ggg.left(qqq 3)="<TD"
x = find(qqq ">")
hhh.right(qqq len(qqq)-x-1)
x=find(hhh "</TD>")
hhh.left(hhh len(hhh)-(len(hhh)-x))
This then makes hhh the data I am looking for.
Is there a better way?
Thanks!
Posts: 12,074
Threads: 141
Joined: Dec 2002
Capture the table and assign to IHTMLTable2 variable.
MSHTML.IHTMLTable2 table=+htm("TABLE" ...)
MSHTML.IHTMLElement cell
foreach cell table.cells
,out cell.innerText
Posts: 37
Threads: 17
Joined: Mar 2005
How do I capture the table? When I try to use the Find HTML Element and Drag button I get BODY and not TABLE.
Thanks again for all your help.
Posts: 12,074
Threads: 141
Joined: Dec 2002
Usually you can capture TABLE, like other types of elements. If it is difficult to capture an element, capture an adjacent element and navigate to the needed element (in this case, TABLE tag) by repeatedly clicking > or < buttons.
Posts: 37
Threads: 17
Joined: Mar 2005
Once again you are right on target with how to do something.
QM is a great program and you offer good, quick technical (how to) support. Well worth the money!!!
Posts: 858
Threads: 196
Joined: Apr 2005
How can I convert the table to bidimensional array?
Posts: 12,074
Threads: 141
Joined: Dec 2002
out
Htm el=htm("TABLE" ...)
MSHTML.IHTMLTable2 table=+el
MSHTML.IHTMLElement cell
MSHTML.IHTMLElementCollection cells=table.cells
int i c r ncol nrow
ncol=3 ;;assume you know it
nrow=cells.length/ncol
ARRAY(str) a.create(ncol nrow)
for c 0 ncol
,for r 0 nrow
,,cell=cells.item(i)
,,a[c r]=cell.innerText
,,i+1
;out array
for r 0 a.len(2)
,out "--------- Row %i ---------" r
,for c 0 a.len(1)
,,out "--- Column %i ---" c
,,out a[c r]
,,