gimx Posted December 19, 2007 Share Posted December 19, 2007 Hello, Why my array doesn't appear plz ? $oTables = _IETableGetCollection ($oIE) For $oTable in $oTables If String ($oTable.className) = "tbl" Then $aTable = _IETableWriteToArray ($oTable) _ArrayDisplay($aTable) EndIf Next Thx Link to comment Share on other sites More sharing options...
weaponx Posted December 19, 2007 Share Posted December 19, 2007 Slightly modified version from the help file example: #include <IE.au3> #include <Array.au3> $oIE = _IE_Example ("table") $oTable = _IETableGetCollection ($oIE) $iNumTables = @extended For $obj In $oTable $aTableData = _IETableWriteToArray ($obj) _ArrayDisplay($aTableData) Next MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page") Link to comment Share on other sites More sharing options...
gimx Posted December 19, 2007 Author Share Posted December 19, 2007 Yes thx, i've just seen my error, sorry i'm tired. But now, i have a "real" problem $oTables = _IETableGetCollection ($oIE) For $oTable in $oTables If String ($oTable.className) = "tbl" Then For $oTR in $oTable MsgBox (1, "test", $oTR.firstChild.innerText) Next EndIf Next I want "surf" in table and get TD[0,3,5] row by row, but this code don't work (no msgbox). I don't understand why because TD in the child of TR no ? Thx Link to comment Share on other sites More sharing options...
weaponx Posted December 19, 2007 Share Posted December 19, 2007 Instead of using innertext, why not just access the array element containing the text? Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 19, 2007 Share Posted December 19, 2007 (edited) Yes thx, i've just seen my error, sorry i'm tired. But now, i have a "real" problem $oTables = _IETableGetCollection ($oIE) For $oTable in $oTables If String ($oTable.className) = "tbl" Then For $oTR in $oTable MsgBox (1, "test", $oTR.firstChild.innerText) Next EndIf Next I want "surf" in table and get TD[0,3,5] row by row, but this code don't work (no msgbox). I don't understand why because TD in the child of TR no ? Thx As Weaponx says, just use the array. The reason your code didn't work is because $oTable is not a collection, so "For $oTR in $oTable" is not going to execute anything. If you want to loop through all <TR>'s for some reason, then use _IETagNameGetCollection(). Fun demo: #include <IE.au3> $oIE = _IE_Example("table") $colTables = _IETableGetCollection($oIE) $t = 0 ; Table index ConsoleWrite("List of table contents where: [Table Index][Row Index][Data Index] = InnerText" & @LF) For $oTable In $colTables $colTRs = _IETagNameGetCollection($oTable, "TR") $r = 0 ; Row index For $oTR In $colTRs $colTDs = _IETagNameGetCollection($oTR, "TD") $d = 0 ; Data index For $oTD In $colTDs ConsoleWrite("[" & $t & "][" & $r & "][" & $d & "] = " & $oTD.innerText & @LF) $d += 1 Next $r += 1 Next $t += 1 Next Edited December 19, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
gimx Posted December 19, 2007 Author Share Posted December 19, 2007 Ok i see, thx all Instead of using innertext, why not just access the array element containing the text? Because i'm a noob and i don't think at this solution The reason your code didn't work is because $oTable is not a collection, so "For $oTR in $oTable" is not going to execute anything. Thx for this explanation and the code Link to comment Share on other sites More sharing options...
gimx Posted December 19, 2007 Author Share Posted December 19, 2007 Sorry, again me... I don't understand how i can write to array all TD i collect. I write a msgbox line to test if the script work and i gett all td in box. After i have tried to use array function but i fail. The innerText attributes is for the test. In fact i want the link and the text in TD row by row. I'm really a noob... $oTables = _IETableGetCollection ($oIE) For $oTable in $oTables If String ($oTable.className) = "tbl" Then $oTRs = _IETagNameGetCollection($oTable, "TR") For $oTR In $oTRs $oTDs = _IETagNameGetCollection($oTR, "TD") For $oTD In $oTDs MsgBox (1, "test", $oTD.innerText) Next Next EndIf Next Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 19, 2007 Share Posted December 19, 2007 Sorry, again me... I don't understand how i can write to array all TD i collect. I write a msgbox line to test if the script work and i gett all td in box. After i have tried to use array function but i fail. The innerText attributes is for the test. In fact i want the link and the text in TD row by row. I'm really a noob... $oTables = _IETableGetCollection ($oIE) For $oTable in $oTables If String ($oTable.className) = "tbl" Then $oTRs = _IETagNameGetCollection($oTable, "TR") For $oTR In $oTRs $oTDs = _IETagNameGetCollection($oTR, "TD") For $oTD In $oTDs MsgBox (1, "test", $oTD.innerText) Next Next EndIf Next I don't know where you got the .className = "tbl" thing, but it just breaks the script for me and no rows get read at all. Maybe this will help: #include <IE.au3> #include <array.au3> $oIE = _IE_Example("Table") Global $avTableData[1] = [0] $oTables = _IETableGetCollection($oIE) $t = 0 For $oTable In $oTables ConsoleWrite("Table " & $t & @LF) $oTRs = _IETagNameGetCollection($oTable, "TR") $r = 0 For $oTR In $oTRs ConsoleWrite("Row " & $r & @LF) $oTDs = _IETagNameGetCollection($oTR, "TD") $d = 0 For $oTD In $oTDs ConsoleWrite("TD = " & $d & @LF) $sTD = $oTD.innerhtml If StringStripWS($sTD, 8) <> "" Then _ArrayAdd($avTableData, $sTD) $d += 1 Next $r += 1 Next $t += 1 Next $avTableData[0] = UBound($avTableData) - 1 _ArrayDisplay($avTableData, "Debug: $avTableData") _IEQuit($oIE) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
gimx Posted December 20, 2007 Author Share Posted December 20, 2007 Thx I will try I don't know where you got the .className = "tbl" thinghttp://msdn2.microsoft.com/en-us/library/m...901(VS.85).aspx Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now