} i can't find a good documentation for Hpricot and aunt google won't help } either. } } so how do you remove html comments with Hpricot? } } i tried things like (html/'!').remove but that doesnt seem to work at } all. } } does anyone know? } thanks!
class Hpricot::Doc def select_nodes selected = queue = children.reverse while node = queue.pop selected << node if yield node queue.push(*node.children.reverse) if node.respond_to? :children end selected end end def Hpricot.orphan_node(node) list = node.parent.children node.parent = nil list.delete(node) end
doc = Hpricot(open('filename.html')) doc.select_nodes { |n| n.comment? }.each { |c| Hpricot.orphan_node(c) }
--Greg