view raw
junkone junkone - 8 months ago 55
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> 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>


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: