For any Element instance , this method
returns an iterator that visits all of E's siblings, that
is, the element children of its parent, in document
order, but omitting E.
E
E.itersiblings(preceding=False)
If the preceding argument is false, the
iterator will visit the siblings following in document
order. If you pass Epreceding=True, the
iterator will visit the siblings that precede in document
order.
E
Example:
>>> root=etree.fromstring(
... "<mom><aaron/><betty/><clarence/><dana/></mom>")
>>> betty=root.find('betty')
>>> for sib in betty.itersiblings(preceding=True):
... print sib.tag
...
aaron
>>> for sib in betty.itersiblings():
... print sib.tag
...
clarence
dana
>>>