title: Reference a sibling's value in a .value() call?
body: <p>I'm trying to get the value of an element out of an xml doc based on the value of a sibling element.  </p>
  
  <p>For example, <code>&lt;data&gt;</code> has a series of <code>&lt;questions&gt;</code>, each <code>&lt;questions&gt;</code> has a series of <code>&lt;answers&gt;</code> and an <code>&lt;answer&gt;</code> that constains the index of the answer the person has chosen.  </p>
  
  <p>What I'm trying to ask is if there's any <code>&lt;questions&gt;</code> in my set that has an <code>&lt;answer&gt;</code> that points to one of the <code>&lt;answers&gt;</code> entries that has an <code>&lt;isCorrect&gt;</code> value of "true".  Right now I just care if one of the questions has a correct answer. </p>
  
  <pre><code>&lt;data&gt;
    &lt;questions&gt;
      &lt;isGraded&gt;true&lt;/isGraded&gt;
      &lt;answers&gt;
        &lt;title&gt;first answer&lt;/title&gt;
        &lt;isCorrect&gt;true&lt;/isCorrect&gt;
      &lt;/answers&gt;
      &lt;answers&gt;
        &lt;title&gt;second answer&lt;/title&gt;
        &lt;isCorrect&gt;false&lt;/isCorrect&gt;
      &lt;/answers&gt;
      &lt;answer&gt;1&lt;/answer&gt;
    &lt;/questions&gt;
    &lt;questions&gt;
      &lt;isGraded&gt;true&lt;/isGraded&gt;
      &lt;answers&gt;
        &lt;title&gt;first answer&lt;/title&gt;
        &lt;isCorrect&gt;false&lt;/isCorrect&gt;
      &lt;/answers&gt;
      &lt;answers&gt;
        &lt;title&gt;second answer&lt;/title&gt;
        &lt;isCorrect&gt;true&lt;/isCorrect&gt;
      &lt;/answers&gt;
      &lt;answer&gt;0&lt;/answer&gt;
    &lt;/questions&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>This is what I'm down to:</p>
  
  <p><code>SET @myValue = @myDoc.value('(/data//questions[isGraded[1]="true"]/child::answers[position() = parent::answer+1][isCorrect="true"])[1]','nvarchar(max)')</code></p>
  
  <p>If I replace the "parent::answer+1" part with the value from the <code>&lt;answer&gt;</code> I get the value I'm looking for, but I don't know how to automatically look at the <code>&lt;answer&gt;</code> elements value to do this.</p>
  
  <p>Or is this even possible?</p>