Hi Thibault,
for node in lxml.Element iters on children of said Element for node in lxml.ObjectifiedElement iters on siblings of said Element Knowing that, I was able to fix my implementation for Objectified ones. This seems like a odd difference between the two and if someone from the team could explain it, I would be eager to know more.
The reason for this behaviourial difference is objectify's intended list-like behaviour of siblings with the same name, to make .dot-operator attribute getattr/setattr access behave much like any regular Python object:
from lxml import etree, objectify root = objectify.fromstring ('<root><x>XXX</x><y>1</y><y>2</y><y>3</y><z>ZZZ</z></root>') print etree.tostring(root, pretty_print=True) <root> <x>XXX</x> <y>1</y> <y>2</y> <y>3</y> <z>ZZZ</z> </root>
[ elem.tag for elem in root.x ] ['x'] [ elem.tag for elem in root.y ] ['y', 'y', 'y'] root.y[0].text # unqualified root.y is a shortcut to index 0 '1' root.y[1].text '2' root.y[2].text '3' root.list_like = ['a', 'b', 'c'] objectify.deannotate(root) # remove type annotations for readability here etree.cleanup_namespaces(root) # remove superfluous ns declarations print etree.tostring(root, pretty_print=True) <root> <x>XXX</x> <y>1</y> <y>2</y> <y>3</y> <z>ZZZ</z> <list_like>a</list_like> <list_like>b</list_like> <list_like>c</list_like> </root>
Best, Holger Landesbank Baden-Wuerttemberg Anstalt des oeffentlichen Rechts Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz HRA 12704 Amtsgericht Stuttgart