I have the following XML:
<root>
<foo>
<bar type="a whole bunch of stuff, then a magic string: MUPPET" />
<value>my Muppet value</value>
</foo>
<foo>
<bar type="some other stuff, then a different magic string: GREMLIN" />
<value>my Gremlin value</value>
</foo>
</root>
I'd like to build an XPath query that returns "my Muppet value" (the string) given the magic string "MUPPET". My guess was:
/root/foo[contains(bar/@type,'MUPPET')]/value/text()
but that doesn't seem to work. I'm really not sure whether that contains(x,y)
operator allows a query as the first parameter. As a side issue, I'm not sure whether I need the text()
on the end.
Any help?