I am using Python 3.12 and lxml.
I want to find a particular tag, and I can do it with elem.find(“tag”). elem is of type Element.
But I want to move child elements of this child into the parent where the child was. For that, I need the index of the child. ANd I can’t find a way to find that index.
lxml’s API description has the _Element.index() method, but I have no idea how to get an _Element instance from an Element instance.
Please advise how to determine that index. (Using a loop instead of find() can do that but I’d like a neater way).