Jump to content
Sign in to follow this  
Giordano

_IeTableGetCollection

Recommended Posts

Giordano

hi people! i got a problem with the UDF IE_T4.au3

i have to read the cells of a table.

i writed this:

$oTable = _IETableGetCollection($oIe,4)
    $Table = _IETableWriteToArray($oTable)
    For $i = 0 To 19
        MsgBox(0,0,$Table[0][$i])
    Next

the first line of table is composed of html tag "TD" and i can read the text inside!

the other lines are composed of "TH" html tag and i can't read them

someone can help me?

thanks


[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]

Share this post


Link to post
Share on other sites
Giordano

i add this to help you helping me ( muttley )

#include<ieT4.au3>
#include<array.Au3>

Global $oIe = _IECreate("http://spaziopertutto.altervista.org/tabella.htm")

MsgBox(0,"Body HTML",_IeBodyReadHTML($oIe))

$oTable = _IETableGetCollection($oIe,0)
$Table = _IETableWriteToArray($oTable)

_ArrayDisplay($Table,0,-1,1)

LOOK WHAT HAPPEN IN THE CELLS "TH" AND LOOK WHAT HAPPEN IN THE CELLS "TD"

why this difference?

Edited by Giordy

[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]

Share this post


Link to post
Share on other sites
Giordano

PROBLEM SOLVED MODIFYING IE.AU3 LIBRARY IN THE FUNCTION _IETABLEWRITETOARRAY

$tds = $tr.GetElementsByTagName("td")

MODIFIED IN

$tds = $tr.GetElementsByTagName("th")

now just the author make the right correction on next relase


[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]

Share this post


Link to post
Share on other sites
Giordano

if someone other got my same problem and want in his table ALL values of a table in IE make these thing:

step 1:

modify your ie.au3 (IE_T4.au3) at the function _IETableWriteToArray whit this:

Func _IETableWriteToArray(ByRef $o_object,$tag)
    If Not IsObj($o_object) Then
        __IEErrorNotify("Error", "_IETableWriteToArray", "$_IEStatus_InvalidDataType")
        SetError($_IEStatus_InvalidDataType, 1)
        Return 0
    EndIf
;
    If Not __IEIsObjType($o_object, "table") Then
        __IEErrorNotify("Error", "_IETableWriteToArray", "$_IEStatus_InvalidObjectType")
        SetError($_IEStatus_InvalidObjectType, 1)
        Return 0
    EndIf
;
    Local $i_cols = 0, $trs, $tr, $tds, $i_col, $i_rows, $col, $row
    $trs = $o_object.rows
    For $tr In $trs
        $tds = $tr.GetElementsByTagName($tag)
        $i_col = 0
        For $td In $tds
            $i_col = $i_col + $td.colSpan
        Next
        If $i_col > $i_cols Then $i_cols = $i_col
    Next
    $i_rows = $trs.length
    Local $a_TableCells[$i_cols][$i_rows]
    $row = 0
    For $tr In $trs
        $tds = $tr.GetElementsByTagName($tag)
        $col = 0
        For $td In $tds
            $a_TableCells[$col][$row] = $td.innerText
            $col = $col + $td.colSpan
        Next
        $row = $row + 1
    Next
    SetError($_IEStatus_Success)
    Return $a_TableCells
EndFunc

i just added the $tag argument in the function so you can choose if see the TH cells or TD cells

step 2:

#include<ieT4.au3>
#include<array.Au3>

Global $oIe = _IECreate("http://spaziopertutto.altervista.org/tabella.htm")

$oTable = _IETableGetCollection($oIe,0)
$Table1 = _IETableWriteToArray($oTable,"td")
$Table2 = _IETableWriteToArray($oTable,"th")

$Table = TableOverTable($Table1,$Table2)

_ArrayDisplay($Table,-1,1)


Func TableOverTable($Table1, $Table2)
    $row=UBound($Table1)
    $col=UBound($Table1,2)
    Local $Table[$row][$col]
    For $i=0 to $row-1
        For $j=0 To $col-1
            If $Table1[$i][$j] = $Table2[$i][$j] Then
                $Table[$i][$j] = $Table1[$i][$j]
            Else
                If $Table1[$i][$j] = "" Then
                    $Table[$i][$j] = $Table2[$i][$j]
                Else
                    $Table[$i][$j] = $Table1[$i][$j]
                EndIf
            EndIf
        Next
    Next
    Return $Table
EndFunc

for who that don't need of this function, just wait the next relase of UDF IE

i hope someone can be helped by this my post


[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]

Share this post


Link to post
Share on other sites
DaleHohm

Hi Giordy,

You must be working with a very old version of IE.au3. You are aware that IE.au3 is part of the standard AutoIt distribution now right? The IE.au3 version in the current beta of AutoIt is V2.4-1.

The issue that you discuss here was discovered and fixed a long time ago. The variable assignment you note now uses:

$tds = $tr.cells

.cells treats TD and TH elements in the same way, so there is no need for special code.

Please be sure you are using the correct version and let me know if you still have trouble.

thanks,

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
Giordano

so i worked for nothing :)

was fun always muttley

thanks for the reply, a month ago i was searching for the page of newest versions of IE.au3 and i downloaded it from the old page, i didn't think that library was yet IN my latest beta :( sorry..

thanks


[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]

Share this post


Link to post
Share on other sites
DaleHohm

Good. Just to be clear, it is not just in the beta... it was put into the production release over a year ago now...

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.