title: How do I formulate this XPath expression for selecting a sibling?
body: <p>How do I formulate an XPath expression for obtaining the attribute value for the first input node following the <code>a</code> node (<code>value A</code>) for the following HTML:</p>
  
  <pre><code>&lt;a href="http://www.link.com"&gt;link&lt;/a&gt;
  &lt;input value="value A" /&gt;
  &lt;input value="value B" /&gt;
  </code></pre>
  
  <p>I tried:</p>
  
  
  
  <pre><code>//input[(preceding-sibling::a[1])]/@value
  </code></pre>
  
  <p>But this gets the value attribute for both input nodes when I only want the attribute for the node for which the <code>a</code> node is the nearest preceding sibling.</p>