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: 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 To: andrea crotti Subject: Re: lxml tostring quoting too much References: 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: 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 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --/e2eDi0V/xtL+Mc8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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) -> "http://something?x=10&y=20" > > 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 --/e2eDi0V/xtL+Mc8 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) iQEcBAEBAgAGBQJSAVxZAAoJEK7pd0+nzJtNSxwH/RHhfO5S5gNHjWAnnt8GSIg+ CE/MtmY5JCYTBtJcvqdjsstuRgjjCbAo12CenxTWtG0kQ+tWC059EM/bL0ZMiMZ0 UZ3n20zGAqXTGHgSsTBLpK7LQz+Lc+c+kNXv+FVgNjpfxR7+Ws6vFo3rSs8QmI/0 P1mQwXHcFRzsRM1mLqKpOHlShfbAdbmCRES7mJR7KDrgNqC9qeAdbcOYheiNh8Ls AIgrjQi4o/kJqOsl8io2RvIO7U5AFYtoLMQ+ypSvU8Jmhzdpq+XggEoxhDG2g2kF B0JgC7dTPYD0OahnK6OaHO8WasHjCDRXZJrqHxfO8Tqk78VpyeZL4jFZtkxmlRI= =PcAy -----END PGP SIGNATURE----- --/e2eDi0V/xtL+Mc8--