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


Groups > comp.lang.python > #52066

Re: lxml tostring quoting too much

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <chris@chrisdown.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.093
X-Spam-Evidence '*H*': 0.81; '*S*': 0.00; 'that?': 0.05; 'xml.': 0.09; 'cc:addr:python-list': 0.11; 'subject:too': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'import': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'from:addr:chris': 0.24; 'received:213.165': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'formed': 0.31; 'quotes': 0.31; 'probably': 0.32; 'url:python': 0.33; 'problem': 0.35; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'should': 0.36; 'url:library': 0.38; 'received:74.125': 0.39; 'either': 0.39; 'skip:x 10': 0.40; 'tell': 0.60; "you're": 0.61; 'content-disposition:inline': 0.62; 'to:addr:gmail.com': 0.65; 'url:x': 0.81; 'andrea': 0.84; 'subject:much': 0.91; 'url:y': 0.91
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to:pgp-key :user-agent; bh=Mn5H8irKnd+4L3W3BkXg3S6CRmm5DnEP+HF53vvbH1s=; b=QH4mUwWjyPihGbg/41jBGqQVrdpjq7LLfIy0wyizaVX+OraJhUjsVZWDWWvTA42grf ib+KuF5DUzz3XETtTcrhaezmxSGHu3NNmzmMWZ7bhxmTW1cE4MCbErfExgrSTpwxLSow ImDBE3ExedrC5P9gQjbAc8dI7/cg9u01hDIBhgCSEmCFgkI/kB8otYRr0pElZrubhXnf eYFAoDCb++YyT4upC9ORSSI6lEko8RCJJDTBnUAtxzbU+Kr7hrgaVDZ14tmAT/zc9vo1 PqMR4+6fmOY78UrePBzTXfzNspJJtbjDadqD0nvmfuCZCVgwjD/d6S99IKCDEQAAMqZE YGPw==
X-Gm-Message-State ALoCoQnk3dS1OxsY+LpLJ6qhs+6NM+Je7BGQ5dCVrXZHH8ea06UkreRvzPIDmrpnVzLK5D2wi//t
X-Received by 10.14.174.194 with SMTP id x42mr2695120eel.87.1375820893088; Tue, 06 Aug 2013 13:28:13 -0700 (PDT)
Date Tue, 6 Aug 2013 22:28:09 +0200
From Chris Down <chris@chrisdown.name>
To andrea crotti <andrea.crotti.0@gmail.com>
Subject Re: lxml tostring quoting too much
References <CAF_E5JaWXk_JkXwx_fbdpV5zvU6Ys5f0+sNkkDj9A0u8M1Ea9A@mail.gmail.com>
MIME-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/e2eDi0V/xtL+Mc8"
Content-Disposition inline
In-Reply-To <CAF_E5JaWXk_JkXwx_fbdpV5zvU6Ys5f0+sNkkDj9A0u8M1Ea9A@mail.gmail.com>
PGP-Key http://chrisdown.name/pgp
User-Agent Mutt/1.5.21 (2010-09-15)
X-Mailman-Approved-At Tue, 06 Aug 2013 23:09:45 +0200
Cc python-list <python-list@python.org>
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.272.1375823386.1251.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375823386 news.xs4all.nl 15927 [2001:888:2000:d::a6]:49014
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52066

Show key headers only | View raw


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

On 2013-08-06 18:38, andrea crotti wrote:
> I would really like to do the following:
>
> from lxml import etree as ET
> from lxml.builder import E
>
> url = "http://something?x=10&y=20"
> l = E.link(url)
> ET.tostring(l) -> "<link>http://something?x=10&y=20</link>"
>
> However the lxml tostring always quotes the &, I can't find a way to
> tell it to avoid quoting it.

You're probably aware, but without the escaping, it is no longer well formed
XML. Why do you want to do that? Is there a larger underlying problem that
should be solved instead?

Either way, you can use "unescape" from the xml.sax.saxutils module[0].

Chris

0: http://docs.python.org/2/library/xml.sax.utils.html

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: lxml tostring quoting too much Chris Down <chris@chrisdown.name> - 2013-08-06 22:28 +0200

csiph-web