From: why the lucky stiff Date: 2006-08-12T09:20:17+09:00 Subject: Re: A simple Hpricot text setter On Fri, Aug 11, 2006 at 03:19:13AM +0900, Chris Gehlker wrote: > If anyone is trying to use Hpricot to clean up the actual content of > a site while leaving the markup alone, theymight find the following > tiny method useful: > > class Hpricot::Text > # Adds a simple Hpricot method to change > # the text embedded in an HTML document > # > # Example of use: > # body.traverse_text do |text| > # text_out = text.to_s > # manupulate text_out > # text.set(text_out) > # end > def set(string) > @content = string > self.raw_string = string > end > end You can also use Elements#inner_html= and Element#inner_html= for this. (body/:a).inner_html = "New Link Text" Also: set, html, remove, append, prepend, before, after, and wrap, which all work just like their JQuery cousins.[1] Thankyou for using Hpricot, it helps the all horses' hearts when you do. _why [1] http://jquery.com/docs/base/