From: Celine Date: 2007-12-20T08:10:02+09:00 Subject: Re: Hpricot syntax different from Xpath ? On 19 déc, 23:30, Chris Shea wrote: > > I'm not sure I understand. Hpricot certainly can access elements that way: > > doc = Hpricot('
one
two
') > > doc.at('body/div[1]').inner_text # => "one" > doc.at('body/div[2]').inner_text # => "two" > doc.at('body/div:eq(0)').inner_text # => "one" > doc.at('body/div:eq(1)').inner_text # => "two" > > Chris Look : doc = Hpricot(open("http://finance.yahoo.com")) (Xpath syntax with DIVs indexed, given by XPather) doc.at('html/body/div[1]/div[2]/div[1]/div[2]/div[1]/div[2]/div[1]/div/ div[1]/div[1]/table/tr[3]/td[2]/span').inner_text => NoMethodError: undefined method `inner_text' for nil:NilClass (without indices for DIVs) doc.at('html/body/div/div/div/div/div/div/div/div/div/div/table/tr[3]/ td[2]/span').inner_text => "2,601.01" So, why ? Celine