views:

264

answers:

1

Hello.

How can I remove img tag/s using nokogiri?

I have the following code but it wont work:

  f = Nokogiri::XML.fragment(str)
  f.search('//img').each do |node| 
    node.remove
  end
  puts f

Thanks for help!

+1  A: 

have a try!

f = Nokogiri::XML.fragment(str)

f.search('.//img').remove puts f

xds2000