I have this HTML snippet
Table of Contents
-
-
I tried mata's response, but for me didn't work:
div_name = 'foo'
my_div = x.xpath(".//div[@id=%s]" %div_name)[0]
I found this on their website http://lxml.de/xpathxslt.html#the-xpath-method for those that might have the same problem :
div_name = 'foo'
my_div = x.xpath(".//div[@id=$name]", name=div_name)[0]