tags:

views:

1592

answers:

1

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"/>
+15  A: 
select="//*[contains(@address,'Downing')]"
vartec
Tested with Notepad++ XML Tools, returns the node fine. Good job.
Stephen Friederichs
Remember to avoid the '//' if possible. :-) Good job though.
Jweede
@Jweede yeah, I know. But as the node wasn't specified, I assumed that he wants every node with that attribute.
vartec
@vartec: Been looking all over for a way to do "like" style searching for the value of an attribute. Thanks!
used2could