title: Use a variable for an Xpath query in Python
body: <p>[N.B. I'm quite new to Python &amp; Xpath]</p>
  
  <p>I was wanting to perform an Xpath query and use a variable in the expression to cycle through all the elements using an index.</p>
  
  <p>For example, rather than having the specific position of <code>[1]</code>, <code>[2]</code>, etc, I'd like to be able to place a variable <code>i</code> in this expression:</p>
  
  <pre><code>for x in root.xpath('/movies/a_movie[i]/studio'):
      print "&lt;studio&gt;" + x.text + "&lt;/studio&gt;"
  </code></pre>
  
  <p>I'm unsure whether it's even possible, but I guess it can't hurt to ask!</p>
  
  <p>To clarify, this is why I would like to do this: I'm trying to process all the elements of <code>a_movie[1]</code>, then at the end of the function, I want to process all the elements of <code>a_movie[2]</code>, and so on.</p>