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


Groups > comp.lang.python > #52129

Re: lxml tostring quoting too much

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.025
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'encoding': 0.05; 'that?': 0.05; 'correct,': 0.09; 'xml.': 0.09; 'cc:addr:python-list': 0.11; 'anyway': 0.14; 'luckily': 0.16; 'subject:too': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'else,': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'somewhere': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message- id:@mail.gmail.com': 0.30; 'formed': 0.31; 'quotes': 0.31; 'probably': 0.32; 'url:python': 0.33; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'url:org': 0.36; 'should': 0.36; 'url:library': 0.38; 'either': 0.39; 'skip:x 10': 0.40; 'tell': 0.60; "you're": 0.61; 'yes': 0.68; 'url:x': 0.81; 'andrea': 0.84; 'subject:much': 0.91; 'url:y': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ZchjM2tsJSmhCR14/y8LqFIr9UKsayuzA7iYP/KXohI=; b=YR4+2WJyODx6U8G6INZdrzdFpLXgmVMBLRgITP00Sfg6iQTHH3ZnJ980iEA5FKb4bW 1pbTKu47QKEwQuhCUh/rhMr/u9BnLvcO8DlAY1J//+EYck32dhg/ymutqkljbXJ1tF9K ax4KlIVqainRMcyZD7rHUJYVioApZt24URBn78wb9iC5HfsZLx7oJBvr/NwU7Byrl2AZ LaFtfbafyqQudLdsvbTNvleCXaEiZiGZnWfO1VK1FbN4wBCHU1V4ZLlNryGdpYeJkqTZ RzSwOo1fHuz+wKe3XJGMvMc9WAKVqbz70JMjJa/c2kda+fXpe+6Xt6iPwOoOR4NoucWK xMKg==
MIME-Version 1.0
X-Received by 10.194.248.130 with SMTP id ym2mr1842712wjc.61.1375872592703; Wed, 07 Aug 2013 03:49:52 -0700 (PDT)
In-Reply-To <20130806202809.GC17412@gopher>
References <CAF_E5JaWXk_JkXwx_fbdpV5zvU6Ys5f0+sNkkDj9A0u8M1Ea9A@mail.gmail.com> <20130806202809.GC17412@gopher>
Date Wed, 7 Aug 2013 11:49:52 +0100
Subject Re: lxml tostring quoting too much
From andrea crotti <andrea.crotti.0@gmail.com>
To Chris Down <chris@chrisdown.name>
Content-Type text/plain; charset=ISO-8859-1
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.312.1375872599.1251.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375872599 news.xs4all.nl 16007 [2001:888:2000:d::a6]:36812
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52129

Show key headers only | View raw


2013/8/6 Chris Down <chris@chrisdown.name>:
> 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

Yes I know it's not correct, I thought that I still had to send that
anyway but luckily the problem was somewhere else, so encoding was
actually necessary and I don't need to do something strange..

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


Thread

Re: lxml tostring quoting too much andrea crotti <andrea.crotti.0@gmail.com> - 2013-08-07 11:49 +0100

csiph-web