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: 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: <20130806202809.GC17412@gopher> Date: Wed, 7 Aug 2013 11:49:52 +0100 Subject: Re: lxml tostring quoting too much From: andrea crotti To: Chris Down Content-Type: text/plain; charset=ISO-8859-1 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: 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 2013/8/6 Chris Down : > 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 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..