How to get following sibling of an etree._Element

lxml, python, python-2.7, xml.etree

Solution

Okay I was wrong. I made a mistake adding the element I found to a new structure before finding the following sibling.

getnext() actually works !

Problem

I am iterating over elements which I find in a xml file like so: ``` for elem in fileasxml.xpath("//elementname[some condition]"): do something ``` Now instead of `do something` I'd like to write the element I have found plus the first following-sibling to a file. Now I know how to write to a file, what I don't know is how to get the following sibling. I've seen the `getnext()` method but it doesn't work since the element I'd like to get is not in `elem`. Same reason I can't use `elem.xpath()` Any ideas ?

Original source