title: Reading the value of an input using XPath, then using in Greasemonkey
body: <p>I'm using this XPath to get the value of a field:</p>
  
  <pre class="lang-none prettyprint-override"><code>//input[@type="hidden"][@name="val"]/@value
  </code></pre>
  
  <p>I get several results, but I only want the first. Using</p>
  
  <pre class="lang-none prettyprint-override"><code>//input[@type="hidden"][@name="val"]/@value[1]
  </code></pre>
  
  <p>Doesn't work. Once I have this, how do I pick up the value in Greasemonkey? I am trying things like:</p>
  
  <pre><code>alert("val " + val.snapshotItem);
  </code></pre>
  
  <p>But I think that's for the node, rather than the string.</p>