I prefer CSS over XPath, as it's usually much more readable. Switching to CSS:
require 'nokogiri'
doc = Nokogiri::HTML('
')
After parsing the document looks like:
doc.to_html
# => "\n\n
\n\n"
Removing the ![]()
tags:
doc.search('img').each do |src|
src.remove
end
Results in:
doc.to_html
# => "\n\n"