How do I remove a node with Nokogiri? March 10, 2023 by Tarik have a try! f = Nokogiri::XML.fragment(str) f.search('.//img').remove puts f