tags:

views:

31

answers:

1

Hello,

I have the following XML

   <question>
    <questiontext>How old are you?</questiontext>
    <options>
      <option oldScore="0" Score="20">17-25</option>
      <option oldScore="8" Score="12">26-30</option>
      <option oldScore="20" Score="2">31-50</option>
      <option oldScore="16" Score="10">51-60</option>
      <option oldScore="12" Score="14" >61-70</option>
      <option oldScore="8" Score="16" >71+</option>
    </options>
  </question>

What I need to be able to do, is select the exact node based on the question text, and option text.

E.g. return the node that has questiontext = "How old are you?" and option="71+"

questions/question[questiontext='How old are you?']/options[option='71+']/option

The above does work, but it ALWAYS returns the first node, not the node I want.

Help! :)

Thanks guys

+2  A: 

Try:

questions/question[questiontext='How old are you?']/options/option[text()='71+']
Quartermeister
Perfect - thank you very much. A blessing on you and your family
Keeno
Oh, could you explain what I did wrong - thanks!
Keeno
You select an options element (/options), which has an element option=71, and of that /options element you select a plain /option, which doesn't have to comply to any other requirements(afaik: all <option>'s should be returned in the resulting set).
Wrikken