Aljaz Aljaz - 1 year ago 112
Ruby Question

How do I remove a node with Nokogiri?

How can I remove

tags using Nokogiri?

I have the following code but it wont work:

# str = '<img src=""/…; testt<a href="#">test</a>tfbu'

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

Answer Source

have a try!

f = Nokogiri::XML.fragment(str)'.//img').remove
puts f
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download