Hpricot how to remove all comments from a document?

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!

On Thu, Dec 21, 2006 at 12:08:27PM +0100, Ralf V. wrote:
} 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© }

–Greg