In Python ElementTree how can I get list of all ancestors of an element in tree ?
- by Rohit
I need "get_ancestors_recursively" function.
A sample run can be
>>> dump(tr)
<anc1>
<anc2>
<element> </element>
</anc2>
</anc1>
>>> input_element = tr.getiterator("element")[0]
>>> get_ancestors_recursively(input_element)
['anc1', 'anc2']
Can somebody help me with this ?