[Rails] Re: Good Rubyistic way Looking for nokogiri program
Love U Ruby wrote in post #1112338:
> doc.search('div').children.reject(&:text?).map{|n| n.name if
> !n.child.to_str.strip.empty? }.compact
> # => ["dt", "dt", "dd"]
I found one shortest way using `css` rules :
doc.search("dt,dd").map{|n| n.name unless n.to_str.strip.empty?
}.compact
# => ["dt", "dt", "dd"]
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7a2f729febb64d3ba6fe05f1572bb477%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home