I am trying to parse elements with certain tag from XML file with Python and generate output excel document, which would contain elements and also preserve their hierarchy.My problem is that I cannot figure out how deeply nested each element (over which parser iterates) is.XML sample extract (3 elements, they can be nested arbitrarily within themselves):\[code\]<A> <B> <C> </C> </B></A><B> <A> </A></B>\[/code\]Following code, using ElementTree, worked well to iterate over elements. But I think ElementTree is not capable determining how deeply each element is nested. See below:\[code\]import xml.etree.ElementTree as ETroot = ET.parse('XML_file.xml')tree = root.getroot()for element in tree.iter(): if element.tag in ("A","B","C"): print(element.tag)\[/code\]This will get me the list of elements A,B,C in right order. But I need to print them out with information of their level,So not only:\[code\]ABCBA\[/code\]But something like:\[code\]A--B----CB--A\[/code\]To be able to do this, I need to get the level of each element. Is there any suitable parser for python which can easily do this? I would imagine something like "element.hierarchyLevel" which would return some Integer index...Thanks a lot for any answer!Vojta