From: 7stud -- Date: 2009-05-22T14:11:26+09:00 Subject: Re: Can I use Hpricot to parse data into different array ele Christiaan Venter wrote: > Hi, > > I have a question about using Hpricot. > > If I do something like this > > doc = open("F:/search.html") { |f| Hpricot(f) } > doc.search(".price").each do |price| > prices = [price.inner_text] > puts prices[0] > > =>$21.95 > $15.95 > > Then it seems that my search results are in an array, but that both > prices are in a single element in the array because both come up when I > ask for the element at [0] > I'm a ruby newbie--what am I missing? > Thanks very much Not understanding loops? Better variable names? require 'rubygems' require 'hpricot' doc = open("html.txt") { |f| Hpricot(f) } doc.search(".price").each do |price_tag| price = price_tag.inner_text puts price end --output:-- $21.95 $15.95 -- Posted via http://www.ruby-forum.com/.