How can unwanted tags be removed from HTML using Nokogiri?
Posted
by sutch
on Stack Overflow
See other posts from Stack Overflow
or by sutch
Published on 2010-03-17T18:55:24Z
Indexed on
2010/03/17
19:31 UTC
Read the original article
Hit count: 242
I need to strip out all font tags from a document. When attempting to do so with the following Ruby code, other elements and text within the font tags are lost. I've also attempted to iterate through all children elements and make them siblings of the font tag before unlinking the font tag--which also results in lost HTML. What is a good method for removing tags which can contain other elements and/or text?
doc.css('font').each do |element|
element.unlink
end
© Stack Overflow or respective owner