[N.B. I'm quite new to Python & Xpath]
I was wanting to perform an Xpath query and use a variable in the expression to cycle through all the elements using an index.
For example, rather than having the specific position of [1], [2], etc, I'd like to be able to place a variable i in this expression:
for x in root.xpath('/movies/a_movie[i]/studio'):
print "<studio>" + x.text + "</studio>"
I'm unsure whether it's even possible, but I guess it can't hurt to ask!
To clarify, this is why I would like to do this: I'm trying to process all the elements of a_movie[1], then at the end of the function, I want to process all the elements of a_movie[2], and so on.
[i]altogether? You are selectingstudioelements that are inside of aa_movieelement, you already would be looping over all matches..a_movie[1], then at the end of the function, I wanted to process all the elements ofa_movie[2].