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


Groups > comp.lang.python > #52129 > unrolled thread

Re: lxml tostring quoting too much

Started byandrea crotti <andrea.crotti.0@gmail.com>
First post2013-08-07 11:49 +0100
Last post2013-08-07 11:49 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#52129 — Re: lxml tostring quoting too much

Fromandrea crotti <andrea.crotti.0@gmail.com>
Date2013-08-07 11:49 +0100
SubjectRe: lxml tostring quoting too much
Message-ID<mailman.312.1375872599.1251.python-list@python.org>
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..

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web