I'm using lxml implementation in python for HTML and XML parsing. Setting up a parser like
parser = lxml.etree.HTMLParser()
and returning a tree from HTML source (string)
tree = lxml.etree.fromstring(html, parser).getroottree() # Returns a XML tree
According to lxml docs, this should return a DOM tree (XML)
I want to find certain elements having tags such as "a", "div", "span", etc.
How can I get the XPath of all possible elements using their tag names?
EDIT: I am actually developing a AJAX crawler, so I need Selenium to click certain elements which can change DOM state. I send the HTML source to the lxml for analysis.
For example, taking default elements in a list like
["a", "button", "li", "nav", "ol", "span", "ul", "header", "footer", "section"]
I need to get xpaths of the above elements so that I can pass them to Selenium for click, and for other event triggers.