Posted on 2010-01-19 11:55:02.590513-08 by alaindesilets
How to select nodes whose descendants have certain properties
I'm a toal newbie with XPath, so please bear with me. I have read through the tutorials and still c +an't figure out how to do what I need. I have an XML file whose structure looks like this: <question> <term> <validity> <decision&gt;yes&lt;/decision> </validity> </term> </question> where the decision could be either yes or no. The file has lots of other tags, but those will suffi +ce for this post. I want to select all the <question> nodes whose decision is 'yes'. I am able to retrieve all the <decision> nodes whose value is yes with this expression: //question/terme/validite[decision='oui'] but I can't figure out how to retrieve the <question> nodes which are ancestors of those. Thank you for your help.
Direct Responses: 12213 | Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.