![](https://secure.gravatar.com/avatar/8b97b5aad24c30e4a1357b38cc39aeaa.jpg?s=120&d=mm&r=g)
Steve, 28.06.2011 22:44:
Stefan Behnel writes:
dev<at> kihonkai.com, 24.06.2011 19:39:
The tutorial (http://lxml.de/tutorial.html#the-e-factory) shows how to create a basic xml document without a namespace and then an example with a namespace.
But how do you apply the namespace to only on element?
It's usually preferable to predefine the tag names, as presented in the second example in the tutorial. Then, you can use getattr() to apply namespaces to single elements, if they differ from the 'normal' namespace of the other tags. Or just use a separate ElementMaker instance.
That has cleared it up now and I was able to get it working using a second ElementMaker instance. I couldn't find anything about getattr() exist on the lxml.objectify page. I've not looked at this at all yet.
That's ok, one ElementMaker per namespace is the intended usage pattern.
But using two ElementMaker instances will work perfectly fine. I was quite close but was just short of getting it working.
I'll add a note to the tutorial.
Oddly this was the first time I finally got round to trying a mailing list. I'm glad I did as it's very easily and quickly solved my issue.
Happy to be of help. Stefan