This is one my best finds so far and would like to share it with you. Here is an example that shows you how to use the xpath contains to build a xpath using part of the attribute value. This can be used when there are elements with the same id or text value.
Here is the source code of the page
Edit
Delete
Now I would like to build the xpath of the Edit link.
//a[contains(@href,'CustomerContacts')][.='Edit']

You can also build the xpath use this syntax
/a[@href[contains(.,'CustomerContacts')]]
Thanks Sam.
The info was useful
[...] using Ruby code Selenium RC with Java and JUnit Sample Selenium RC Script using TestNG Eclipse How to use contains to get the attribute value in xpath Author: Pavandeep Puddupakkam on March 5, 2011 Category: Selenium RC Tags: [...]
i wanted to implement your solution for the following html:
Hi Shane
should – //a[contains(@href,'Hi')] work?
Hi barryhorgan