![](https://secure.gravatar.com/avatar/bc4259003fffe3e1cb3543db975bea0d.jpg?s=120&d=mm&r=g)
Hi Volker,
A week ago I formulated a quite simple lxml.objectify question on stackoverflow and got no answer, yet. https://stackoverflow.com/questions/71212909/python-lxml-objectify-gives-no-... Since I don't get an easy answer I conclude that my feeling about something is wrong in lxml.objectfy is not a mare. So I elevate this topic to the mailing list. Any help appreciated Volker Jaenisch
This is expected and just how lxml.objectify works. Since {http://www.isotc211.org/2005/gco}CharacterString is from another namespace than its parent element ({"http://www.isotc211.org/2005/gmd}fileIdentifier) it cannot be retrieved from the parent with "simple (dot) attribute lookup". Instead you have to you use index access (just like you already did) or getattr: ```
from lxml import etree, objectify data = objectify.fromstring( ... """<gmd:MD_Metadata ... xmlns:gmd="http://www.isotc211.org/2005/gmd" ... xmlns:gco="http://www.isotc211.org/2005/gco" > ... <gmd:fileIdentifier> ... <gco:CharacterString>2ce585df-df23-45f6-b8e1-184e64e7e3b5</gco:CharacterString> ... </gmd:fileIdentifier> ... <gmd:language> ... <gmd:LanguageCode codeList="https://www.loc.gov/standards/iso639-2/" codeListValue="ger">ger</gmd:LanguageCode> ... </gmd:language> ... </gmd:MD_Metadata> ... """) data.fileIdentifier["{http://www.isotc211.org/2005/gco}CharacterString"] '2ce585df-df23-45f6-b8e1-184e64e7e3b5' getattr(data.fileIdentifier, "{http://www.isotc211.org/2005/gco}CharacterString") '2ce585df-df23-45f6-b8e1-184e64e7e3b5'
The reason for this is that obviously {http://www.isotc211.org/2005/gco}CharacterString is not a valid Python identifier and it makes sense
to restrict unqualified lookup to children from the same namespace.
See also "Namespace handling" in the official docs: https://lxml.de/objectify.html#the-lxml-objectify-api
Best,
Holger
Landesbank Baden-Wuerttemberg
Anstalt des oeffentlichen Rechts
Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz
HRA 12704
Amtsgericht Stuttgart
HRA 4356, HRA 104 440
Amtsgericht Mannheim
HRA 40687
Amtsgericht Mainz
Die LBBW verarbeitet gemaess Erfordernissen der DSGVO Ihre personenbezogenen Daten.
Informationen finden Sie unter https://www.lbbw.de/datenschutz.