lxml question -- creating an etree.Element attribute with ':' in the name
Zachary Ware
zachary.ware+pylist at gmail.com
Wed Sep 18 15:07:33 EDT 2013
On Wed, Sep 18, 2013 at 1:59 PM, Roy Smith <roy at panix.com> wrote:
> I can create an Element with a 'foo' attribute by doing:
>
> etree.Element('my_node_name', foo="spam")
>
> But, how do I handle something like:
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance", since "xmlns:xsi" isn't a valid python identifier?
>
Try this:
etree.Element('my_node_with_invalid_identifiers_name', **{'xmlns:xsi': 'spam'})
HTH,
--
Zach
More information about the Python-list
mailing list