Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75353
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <glicerinu@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.066 |
| X-Spam-Evidence | '*H*': 0.87; '*S*': 0.00; 'none:': 0.07; '8bit%:30': 0.09; 'attributes': 0.09; 'wrote:': 0.18; 'trying': 0.19; '>>>': 0.22; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'print': 0.22; '>>>': 0.24; 'skip:e 30': 0.24; "i've": 0.25; 'skip:" 40': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'idea': 0.28; 'xml': 0.29; '8bit%:3': 0.30; 'skip:& 60': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; "skip:' 10": 0.31; '"",': 0.31; 'doc': 0.31; 'marc': 0.31; 'received:google.com': 0.35; 'doing': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'skip:x 10': 0.40; 'how': 0.40; 'it!': 0.67; 'jul': 0.74; 'desperately': 0.84; 'skip:) 10': 0.84; 'xmlns:xsi': 0.84; 'imagine': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=FtiOhxJeUtXd378J8kOEgI1lLpRhA8FeQolQYtNF/8A=; b=sGQ0bult7GQKMqo0OS2ITxfcNSPE3oD/RZ3exYvD619iAdAvcoBVDJMdJSzkt76VGd lwVWz/neBvD4oz7u6OfPqxiMwGPijPZytZUIyHWeDVqHR/LzN4H5o5ARucKTijWzTxoB EsJeBi6y1uQN3lvRIgsJWLvqsbKEJ/frqpRax3AxGO8tUiE+UpxxSDnkKij1l6rDwKI1 vgTdWgeWBXThMVJ/NwCElYyRy0AIj0q0QDK3L6fq6pvNqIrQJtgAR+R4CiNI/Sj0KTF9 0+4JSKLT65EULp1pU25TPP+H7xfcW0s1BYQtYJkenJWNXm1SYg0yxfIxunuqY0huKHLz Yo7w== |
| X-Received | by 10.152.26.39 with SMTP id i7mr4587321lag.14.1406658975265; Tue, 29 Jul 2014 11:36:15 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <CA+DCN_sgzzVgLmuvN-ogk6gSLXzuLqZPTj6vH=JQRFsCa_KNrQ@mail.gmail.com> |
| References | <CA+DCN_sgzzVgLmuvN-ogk6gSLXzuLqZPTj6vH=JQRFsCa_KNrQ@mail.gmail.com> |
| From | Marc Aymerich <glicerinu@gmail.com> |
| Date | Tue, 29 Jul 2014 20:35:55 +0200 |
| Subject | Re: lxml and namespaces |
| To | "comp.lang.python" <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=089e0158bebe8a78dc04ff59505d |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12420.1406658982.18130.python-list@python.org> (permalink) |
| Lines | 111 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1406658982 news.xs4all.nl 2961 [2001:888:2000:d::a6]:51575 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75353 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Tue, Jul 29, 2014 at 8:19 PM, Marc Aymerich <glicerinu@gmail.com> wrote:
> 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?
>
Got it!
xml = lxml.builder.ElementMaker(
nsmap = {
None: "urn:iso:std:iso:20022:tech:xsd:pain.008.001.02",
'xsi': "http://www.w3.org/2001/XMLSchema-instance",
}
)
doc = xml.Document()
--
Marc
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: lxml and namespaces Marc Aymerich <glicerinu@gmail.com> - 2014-07-29 20:35 +0200 Re: lxml and namespaces Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2014-07-29 21:21 +0200
csiph-web