xpath: find a node that has a given attribute whose value contains a string

flybywire picture flybywire · Mar 5, 2009 · Viewed 70.5k times · Source

Is there an xpath way to find a node that has a given attribute whose value contains a given string?

For example I have an xml document and want to find a node where the address attribute contains the string Downing, so that I could find the following node:

<person name="blair" address="10 Downing St. London"/>

Answer

vartec picture vartec · Mar 5, 2009
select="//*[contains(@address,'Downing')]"