hpricot:An Hpricot Showcase:Hpricot Challenge:Selecting the text from actual node only
まんま
require "hpricot" X =<<EOS <div id="myid"> <h4>title</h4> sample text </div> EOS doc = Hpricot(X) p doc.at('#myid').children.select{|e| e.text?}
で、
["\n ", "\n sample text\n"]