[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Hpricot and XPaths with indices

Peter Szinek

10/6/2006 12:43:00 PM

Hello,

I just started to use HPricot a few days ago (what a cool piece of
software! ;-) so it is possible that I have just overlooked it but I did
not find a way to evaluate XPaths with indices yet. Instead of a general
XPath, e.g.:

(doc/'//div/table/tr/td/img')

I would like to lookup an indexed one:

(doc/'//div[2]/table[3]/tr[2]/td[8]/img[2]').

OK, I guess this is doable by ((doc/'//div)[2]./table)[3]... or
something similar, but is this the only (and accepted) way?

TIA,
Peter
http://www.rubyra...

2 Answers

David Vallner

10/7/2006 12:54:00 AM

0

http://code.whytheluckystiff.net/hpricot/wiki/SupportedXpathE...

Yay rftdocs. Hpricot's XPath syntax seems quite incomplete, either e.g.
div:eq(0) will work or nothing will.

David Vallner


why the lucky stiff

10/8/2006 3:48:00 AM

0

On Sat, Oct 07, 2006 at 09:53:51AM +0900, David Vallner wrote:
> http://code.whytheluckystiff.net/hpricot/wiki/SupportedXpathE...
>
> Yay rftdocs. Hpricot's XPath syntax seems quite incomplete, either e.g.
> div:eq(0) will work or nothing will.

Very true. And there are plans to enhance:
http://code.whytheluckystiff.net/hpric...

Unfortunately, I am six days late as of this day. That is frownworthy, I know.

_why