Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75352 > unrolled thread

lxml and namespaces

Started byMarc Aymerich <glicerinu@gmail.com>
First post2014-07-29 20:19 +0200
Last post2014-07-29 20:19 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  lxml and namespaces Marc Aymerich <glicerinu@gmail.com> - 2014-07-29 20:19 +0200

#75352 — lxml and namespaces

FromMarc Aymerich <glicerinu@gmail.com>
Date2014-07-29 20:19 +0200
Subjectlxml and namespaces
Message-ID<mailman.12419.1406657979.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Hi, I'm desperately trying to construct an XML with the following document
declaration:

<Document xmlns=”urn:iso:std:iso:20022:tech:xsd:pain.008.001.02”
        xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>

I'm using LXML, and what I'm doing is this

>>> from lxml import etree
>>> from lxml.builder import E
>>> doc = E.Document(
...     {
...         'xmlns': "urn:iso:std:iso:20022:tech:xsd:pain.008.001.02",
...         '{xmlns}xsi': "http://www.w3.org/2001/XMLSchema-instance",
...     }
... )
>>> print etree.tostring(doc)
<Document xmlns:ns0="xmlns" ns0:xsi="
http://www.w3.org/2001/XMLSchema-instance"
        xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"/>


I've tried everything I can imagine and this is the best I can do :(

Any idea on how to get the xmlns and xmlns:xsi attributes correctly?

Thanks!!

-- 
Marc

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web