Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading an internet table
#1
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).
#2
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!
#3
Capture the table and assign to IHTMLTable2 variable.

Code:
Copy      Help
MSHTML.IHTMLTable2 table=+htm("TABLE" ...)
MSHTML.IHTMLElement cell
foreach cell table.cells
,out cell.innerText
#4
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.
#5
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.
#6
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!!!
#7
How can I convert the table to bidimensional array?
#8
Code:
Copy      Help
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]
,,


Forum Jump:


Users browsing this thread: 4 Guest(s)