tags:

views:

12

answers:

1

I have two anchor tags that differ only because the second one does not contain the word "Report" in the anchor text or in the address link.

<a href="http://www.example.com/data/invoices/2010/10/invoices-report---tuesday-october-12.html"&gt;Invoices Report - Tuesday, October 12</a>

<a href="http://www.example.com/data/invoices/2010/10/invoices---tuesday-october-12.html"&gt;Invoices - Tuesday, October 12</a>

How would you identify the first link with XPath and avoid identifying the second?

+1  A: 

How would you identify the first link with XPath and avoid identifying the second?

There are many ways of doing this:

//a[contains(., 'Report')]

or

//a[contains(@href,'report')]

Both of these XPath expressions select the first a element and don't select the second a element.

Dimitre Novatchev