From: Mark Thomas Date: 2008-08-13T04:27:35+09:00 Subject: Re: extract value of the hpricot elem On Aug 12, 2:04 pm, Junkone wrote: >  url="http://www.nasdaq.com/aspxcontent/shortinterests.aspx? > symbol=FRE&selected=FRE" > doc=open(url) {|f| Hpricot(f)} > doc.search("//table[@class='dataGrid']") > rqTable=doc.search("//table[@class='dataGrid']") > rqTable.search('tr').each{|tr| > > tdArray=tr.search('td') > >         dataArray=Array.new >         #tr.search('td').each{|td| >         #       puts td.inner_text >         #       } > >         puts tdArray[0].class,tdArray[1].to_s,tdArray[2] >         puts "end" > > } > > how do i get the text value of the tdArray[0] which is internally a > Hpricot::Elem It's often easier to simply go directly to what you want with XPath. I'm not sure exactly what you want to extract, but try this: require 'open-uri' url="http://www.nasdaq.com/aspxcontent/shortinterests.aspx? symbol=FRE&selected=FRE" doc=Hpricot(open(url)) rqTable=doc.search("//table[@class='dataGrid']//td/text()") puts rqTable.inspect