Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54393 > unrolled thread
| Started by | Zachary Ware <zachary.ware+pylist@gmail.com> |
|---|---|
| First post | 2013-09-18 14:07 -0500 |
| Last post | 2013-09-18 14:07 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| 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 |
| Message-ID | <mailman.129.1379531615.18130.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web