Skip to content Skip to sidebar Skip to footer

How Do I Select Either A Th Or A Td From A Table Row?

I'm using Nokogiri with Rails 5. How do I select either a 'th' element or a 'td' element from a table row? My goal is to get all the text of cells in a row (if there is a more ge

Solution 1:

Use a , (comma) to select multiple nodes:

row_values = row.css('td, th').map{|str| str.text }

Post a Comment for "How Do I Select Either A Th Or A Td From A Table Row?"