From: Chris Shea Date: 2007-12-20T07:30:16+09:00 Subject: Re: Hpricot syntax different from Xpath ? On Dec 19, 2007 2:45 PM, Celine wrote: > Yes, thanks, it runs. > There's something I can't understand : in the Xpath expression I > posted later, when a node has several child DIVs, I access them with > an index (div[2]...), but in Hpricot syntax, DIVs aren't accessed > using an index. So, what trick Hpricot uses to locate "the good" div ? 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