Given an XML document such as this:
<root>
<foo>
<bar>a</bar>
<bar>b</bar>
<bar>c</bar>
</foo>
...
</root>
How can I retrieve all foo
-nodes that have bar
-subnodes with certain values?
So for instance, if I need all foo
-elements that have bar
-subelements with values a
and c
, I am currently using this expression:
//*/foo[bar/text()='a'][bar/text()='c']
which is fine, except that it gets clumsy if I have more "bar
-constraints" and I'm not too big of a fan of programmatically generated XPath expressions :). What I am looking for is something along these lines (obviously invalid syntax):
//*/foo[bar/text() in-set('a', 'c')]
Any ideas?