junkone junkone - 11 months ago 68
Ruby Question

how to print title from SPAN tag

I am using 'Nokogiri' . How can I print out the title from inside this span tag?
when I use puts row.css('td.calendar__impact').css('span').title it returns empty

irb(main):063:0> rows.map do |row|
irb(main):064:1* puts row.css('td.calendar__impact').css('span')
irb(main):065:1> end

<span title="Low Impact Expected" class="low"></span>
<span title="Low Impact Expected" class="low"></span>

Answer Source

is returning an array, so you might want to loop though it to get the title for all the span elements.

This is how you would access the attributes and get the title for the first span element: