tags:

views:

384

answers:

1

http://stackoverflow.com/questions/1474688/nokogiri-how-to-select-nodes-by-matching-text

can do thsi via Xpath

however, i am looking for a way to do a CSS select by matching the text of element.

PyQuery, PHPQuery can do this. Isnt there a Jquery API lib for ruby ?

+1  A: 

Cannot be done with pure CSS, you'll have to mix it with Ruby code

  doc = Nokogiri::HTML("<p>A paragraph <ul><li>Item 1</li><li>Apple</li><li>Orange</li></ul></p>")
  p doc.css('li').select{|li|li.text =~ /Apple/}
Adrian