Since you're editing HTML, I'd use Nokogiri:
http://nokogiri.org/tutorials/modifying_an_html_xml_document.html

-- 
Posted via http://www.ruby-forum.com/.