jbnv Posted April 27, 2015 Posted April 27, 2015 ; $oTable: HTML <table> element Func IterateTableRows(ByRef $oTable) For $oTr In $oTable.rows Sleep(1000) ConsoleWrite("(" & $oTr.className & ") ") If Not ($oTr.className = "tblGridView_row1" Or $oTr.className = "tblGridView_row2") Then ContinueLoop ... ; following details omitted Next EndFuncThe purpose of this code is to process the rows of the class "tblGridView_row1" or "tblGridView_row2." It's not doing that. Given the following table (simplified for brevity):<table> <tbody> <tr align="center" class="tblGridView_header">...</tr> <tr class="tblGridView_row1">...</tr> <tr class="tblGridView_row2">...</tr> <tr class="tblGridView_row1">...</tr> <tr class="tblGridView_row2">...</tr> <tr class="tblGridView_row1">...</tr> <tr class="tblGridView_row2">...</tr> <tr class="pagination">...</tr> </tbody> </table>The ConsoleWrite call should output "(tblGridView_header) (tblGridView_row1) (tblGridView_row2) (tblGridView_row1) (tblGridView_row2) (tblGridView_row1) (tblGridView_row2) (pagination)". But instead the output is "(tblGridView_header) (tblGridView_row1) () () () () () ".What is happening here and how do I fix it?
mikell Posted April 27, 2015 Posted April 27, 2015 Using the provided code it works for me#include <IE.au3> Local $oIE = _IECreate() $oIE.visible = 0 Local $sHTML = FileRead("1.html") _IEBodyWriteHTML($oIE, $sHTML) Sleep(100) $oTable = _IETableGetCollection($oIE, 0) IterateTableRows($oTable) ; $oTable: HTML <table> element Func IterateTableRows(ByRef $oTable) For $oTr In $oTable.rows Sleep(1000) ; ConsoleWrite("(" & $oTr.className & ") ") If Not ($oTr.className = "tblGridView_row1" Or $oTr.className = "tblGridView_row2") Then ContinueLoop ; following details omitted ConsoleWrite("(" & $oTr.className & "-test) ") Next EndFunc
jbnv Posted April 27, 2015 Author Posted April 27, 2015 Looking at it again, I realized that the code that I omitted does a postback, which surely destroys the table object that I am trying to read. So what I need to do is make a hard copy of the table parameter and iterate over that.
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