From: Bart Braem Date: 2006-10-11T20:50:07+09:00 Subject: Re: Webpage to RSS why the lucky stiff wrote: > I'm not sure I understand exactly, but here's my impression of what you're > trying to do. > > doc = Hpricot(html_string) > (doc/:h3).each do |ele| > rss_title = ele �# okay, so you have the 3rd-level header > rss_contents = Hpricot::Elements[] > > while ele = h3.next_sibling > rss_contents << ele > break if ele.respond_to?(:name) and ele.name == "ul" > end > end > > So, basically, you can use `next_sibling` (or `previous_sibling`) to walk > back and forth between HTML brothers and sisters. �I store it in an > Hpricot::Elements array, since you can then just call > `rss_contents.to_html` or do other searches on it. > > This is available since changset [49], so you'll need to either install > from SVN or monkeypatch. The next_sibling and previous_sibling methods are just what I needed. Now for an svn checkout... Thanks a lot! Bart