[lxml-dev] Proper syntax to insert elements with namespaces?

Mike MacCana mmaccana at au1.ibm.com
Fri Jul 18 09:17:38 CEST 2008


On Tue, 2008-07-15 at 12:16 +0200, Stefan Behnel wrote:

> Mike MacCana wrote:



> > - I haven't been able to find any examples of setting a namespace to
> > apply to an attribute - so that the stylename attribute has the text
> > namespace (as OpenDocument seems to do things).
> >
> > - Additionally If I set the attribute to be style-name instead of
> > stylename, I get
> > 'SyntaxError: keyword can't be an expression'.
> > OK, I understand that. But I when I quote this so the dash comes out
> > literally, lxml complains about invalid syntax.
> 
> Same solution for both:
> 
>     ns = "{...}"
>     Element(ns+"p", attrib={ns+"style-name" : "Standard"})
> 
> (and I admit that that's missing from the tutorial)
> 
> Stefan


Thanks muchly Stefan. When I get my OpenDocument test running I'll pop
the code back to the list.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/lxml-dev/attachments/20080718/bc25d973/attachment.htm 


More information about the lxml-dev mailing list