bacrotoubcuse
New Member
I can't figure out how to get a table cell's text() whether or not an anchor tag is parent to the text.WITH:\[code\] <td class="c divComms" title="Komentarz|"> <a id="List1_Dividends_ctl01_HyperLink1" target="_blank" href="http://www.attrader.pl/pl/akcje/DRUKPAK/komunikat/EBI/none,20130104_090845_0000041461">uchwalona</a> <div class="stcm">2013-01-29</div></td>\[/code\]WITHOUT:\[code\]<td class="c divComms" title="Komentarz|Celem...">proponowana<div class="stcm">2012-10-05</div></td>\[/code\]Composing elements of a hash, I would expect\[code\] details = rows.collect do |row| detail = {} [ [aystatus, 'td[7]//text()[not(ancestor::div)]'], [aydate, 'td[7]/div/text()'], # the 2013-01-29 or 2012-10-05 above ].each do |name, xpath| detail[name] = row.at_xpath(xpath).to_s.strip end\[/code\]to catch either uchwalona or proponowana (notice without the date in the trailing div), but as it stands, it ignores the \[code\]a\[/code\] tag text, unless I do \[code\]td[7]/a/text()\[/code\], in which case only the anchor's text "uchwalona" is read.