From: Wild Al Date: 2006-10-09T04:54:16+09:00 Subject: Re: Stripping unwanted html eden wrote: > > Here's a modified version of what I came up with, maybe you'll find it > useful? > > def strip_tags_except(html, exceptions = []) > if html.index("<") > text = "" > tokenizer = HTML::Tokenizer.new(html) > while token = tokenizer.next > case node = HTML::Node.parse(nil, 0, 0, token, false) > when HTML::Tag > text << node.to_s if exceptions.include?(node.name) > when HTML::Text > text << node.to_s > end > end > text > else > html > end > end I found this method very useful; it is exactly what I needed. Thanks. To all others: your suggestions helped too, especially in understanding ruby. Thanks again... -- Posted via http://www.ruby-forum.com/.