Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54393
| References | <F1EF559F-76E7-42F4-AC96-5EC0E8B6DBA1@panix.com> |
|---|---|
| From | Zachary Ware <zachary.ware+pylist@gmail.com> |
| Date | 2013-09-18 14:07 -0500 |
| Subject | Re: lxml question -- creating an etree.Element attribute with ':' in the name |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.129.1379531615.18130.python-list@python.org> (permalink) |
On Wed, Sep 18, 2013 at 1:59 PM, Roy Smith <roy@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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: lxml question -- creating an etree.Element attribute with ':' in the name Zachary Ware <zachary.ware+pylist@gmail.com> - 2013-09-18 14:07 -0500
csiph-web