Bart Braem
10/11/2006 11:50:00 AM
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