From: William James Date: 2005-01-26T04:45:48+09:00 Subject: Re: is my installation not working? Previous version was too bloated. .. class String .. def span( tagname ) .. self.scan( Regexp.new( .. '(<'+tagname+'.*?>)(.*?)', .. Regexp::MULTILINE ) ) { |a,b| yield a,b } .. end .. def get_attr .. h = Hash.new .. self.scan( /(\w+)="([^"]*)"/m ).each { |a,b| .. h[ a ] = b } .. h .. end .. end .. .. s = '' .. $<.each_line {|x| s=s+x} .. .. s.span('section') { |tag,text| .. puts "Section: " + tag.get_attr['name'] .. text.span('item') { |tag,text| .. a = tag.get_attr .. puts " Item: upc=#{a['upc']} stock=#{a['stock']}" .. text.span('name') { |tag,name| .. puts " Name: " + name .. } .. text.span('price') { |tag,price| .. puts " Price: " + price .. } .. } .. }