From: Mikel Lindsaar Date: 2007-10-25T16:49:23+09:00 Subject: Re: Need help parsing HTML with Hpricot... Of course... you could also do: require 'rubygems' require 'hpricot' text =< This is another line of text
It keeps going on like this

Until a new paragraph is started
Otherwise, it's just more of the same
HERE class String def not_needed? self.strip == "
" ? true : false end end @parsed_html = Hpricot(text) @paragraphs = Array.new @parsed_html.each_child_with_index do |c,i| line = c.to_s.strip if line == "" puts "

#{@paragraphs}

" @paragraphs.clear else @paragraphs << "#{line} " unless line.not_needed? end end Which produces:

This is one line of text This is another line of text It keeps going on like this

Until a new paragraph is started Otherwise, it's just more of the same

Now... don't pick on my favorite HTML parser again! :D Just ask nicely :) Mikel