Using position

56 views
Skip to first unread message

cornel b

unread,
May 31, 2011, 10:01:36 AM5/31/11
to FirePath
If I go to a page that has multiple selects, how do I select one of
them by index? The page in question doesnt have ids or unique class
names for those selects so I'd really like to be able to use something
like:

//select[position()=1]

Thanks,

Pierre Tholence

unread,
Jun 5, 2011, 9:35:18 AM6/5/11
to fire...@googlegroups.com
Hi,

I think the XPath expression you are looking for in this situation is:
/descendant::select[1]

As you can see in the xPath specification: http://www.w3.org/TR/xpath/#path-abbrev
NOTE: The location path //para[1] does not mean the same as the location path /descendant::para[1]. The latter selects the first descendant para element; the former selects all descendant para elements that are the first para children of their parents.

So //select[position() = 1] which is equivalent to //select[1] will probably not give you what you want.

Regards,
Pierre
Reply all
Reply to author
Forward
0 new messages