stu@sente ~ $ ipython
In [1]: import lxml.html
In [2]: root = lxml.html.parse("http://docs.python.org/").getroot()
In [3]: print "there are %d links in the document" % len(root.xpath('//a'))
there are 40 links in the document
In [4]: for table in root.xpath('//table'):
...: print "there are %d links found" % len(table.xpath('//a'))
...:
there are 40 links found
there are 40 links found
there are 40 links found
In [5]: print "but there are only %d links within the three tables" % len(root.xpath('//table//a'))
but there are only 21 links within the three tables
In [6]: # can I somehow get the 'table.xpath()' which starts the xpath() query at the table node?
In [7]: