objectify and namespaces weirdnes

Hi I'm scratching the surface of the lxml library and found objectify. I have xml file like this: http://pastebin.com/3bE1rSpW and would like to objectify it. The point is I have no idea how to deal with namespaces there. what I'm doing ...
tree=objectify.parse("file.xml",parser) root=tree.getroot() root.studenci.tag
.... AttributeError: no such child: {urn:polon:plikImp:1_5}studenci or any other child. Well, what I'm missing here? I am a bit confused about the name space syntax. How can I get to the different children in this objectified file? P.

Hi,
http://pastebin.com/3bE1rSpW ...
tree=objectify.parse("file.xml",parser) root=tree.getroot() root.studenci.tag
.... AttributeError: no such child: {urn:polon:plikImp:1_5}studenci
lxml works with fully-qualified namespaced tags. From the (docs http://lxml.de/objectify.html#the-lxml-objectify-api): "If you access a child of an Element without specifying a namespace, the lookup will use the namespace of the parent" Now, in your XML file only the root element lives in namespace "urn:polon:plikImp:1_5" as it is prefixed with ns0 while (all the other) unprefixed elements live in no namespace. You should be able to get at the subelements using root['{}studenci'] as described in the docs' namespace handling (if you are running on lxml >= 2.3: https://mailman-mail5.webfaction.com/pipermail/lxml/2010-November/005769.htm...). This is the way to retrieve subelements in a different namespace from their parent's namespace. But maybe you're able to change the XML file and actually want all these elements to live in the same namespace? Then you could change your root element to e.g. <plikImp xmlns="urn:polon:plikImp:1_5" xmlns:funk="urn:polon:imp:slownik:funkcjaOsobyWInstytucji:1_5" xmlns:stanowiskoPN="urn:polon:imp:slownik:stanowiskoPN:1_5" xmlns:spec="urn:polon:imp:slownik:specjalnosc:1_5" xmlns:dd="urn:polon:imp:slownik:dziedzinaDyscyplina:1_5" xmlns:ss="urn:polon:imp:slownik:stopienStudiow:1_5" xmlns:tz="urn:polon:imp:slownik:tytulZawodowy:1_5" xmlns:sna="urn:polon:imp:slownik:stanowiskoNA:1_5" xmlns:c="urn:polon:imp:wspolne:wspolne:1_5" xmlns:student="urn:polon:imp:element:student:1_5" xmlns:pracDydNauk="urn:polon:imp:element:pracownikNaukowy:1_5" xmlns:kandydatStat="urn:polon:imp:element:kandydatStatystyka:1_5" xmlns:kraj="urn:polon:imp:slownik:kraj:1_5" xmlns:specFil="urn:polon:imp:slownik:specjalnoscFilologia:1_5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:polon:plikImp:1_5 plikImp.xsd"> and just use simple root.studenci access. Holger -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
participants (2)
-
jholg@gmx.de
-
Piotr Oh