I\'m searching in a HTML document using XPath from lxml in python. How can I get the path to a certain element? Here\'s the example from ruby nokogiri:
If all you have in your section of code is the element and you want the element's xpath do then element.getroottree().getpath(element) will do the job.
from lxml import etree
xml = '''
'''
tree = etree.fromstring(xml)
for element in tree.iter():
print element.getroottree().getpath(element)