Enubnoittee
New Member
I think the best way to explain this is via some code. Basically the only way to identify the TR I need inside the table (i've already reached the table itself and named it annual_income_statement) is by the text of the first TD in the TR, like this:this may be helpful to know, too:html snippet:\[code\]<div id="incannualdiv"> <table id="fs-table"> <tbody> <tr>..</tr> ... <tr> <td>Net Income</td> <td>100</td> </tr> <tr>..</tr> </tbody> </table></div>\[/code\]original xpath\[code\]irb(main):161:0> annual_income_statement = doc.xpath("//div[@id='incannualdiv']/table[@id='fs-table']/tbody")\[/code\]\[code\]\[/code\]\[code\]irb(main):121:0> a = nil=> nilirb(main):122:0> annual_income_statement.children.each { |e| if e.text.include? "Net Income" and e.text.exclude? "Ex"irb(main):123:2> a = e.textirb(main):124:2> end }=> 0irb(main):125:0> a=> "Net Income\n\n191.00\n611.00\n254.00\n-1,151.00\n"irb(main):127:0> a.split "\n"=> ["Net Income", "", "191.00", "611.00", "254.00", "-1,151.00"]\[/code\]but is there a better way?