I often load test Drupal webapps with jmeter. One thing that I need to do very often is grab the form_build_id (unique for every form invocation) and use it for the form submit.
For a very simple form (only one form_build_id on the page), this works:
in the Xpath extractor, set the reference name to whatever you want. I often set a default value of, e.g., form_build_id_no so I can easily tell (in a Debug Sampler) that no value was found and therefore the xpath isn't quite right.
The @id extracts just the id attribute from the input element.