--0016364ed9d4e33cd70476c5d263
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Oct 25, 2009 at 5:31 AM, Fernando Perez <pedrolito / lavache.com>wrote:

> Hi,
>
> In one of my Rails app, I have a content attribute that hosts some html
> code. I want to parse this content and replace <img> tags by something
> else. I used to do Nokogiri::HTML(content), and then do my parsing, then
> return the content.
>
> The problem is that nokogiri injects the doctype and <html><body> tags
> which obviously messes up my final html page because of these duplicate
> tags.
>
> So how to perform the parsing without having to first initialize the
> content with Nokogiri::HTML, or how to not initialize a full html page
> from my content?
>

Try Nokogiri::HTML::DocumentFragment.parse(content).


>
> Cheers,
> --
> Posted via http://www.ruby-forum.com/.
>
>


-- 
mike dalessio
mike / csa.net

--0016364ed9d4e33cd70476c5d263--