xml input sanitizing method in standard lib?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Mar 10 13:36:25 CET 2009


En Tue, 10 Mar 2009 05:40:10 -0200, Stefan Behnel <stefan_ml at behnel.de>  
escribió:
> Gabriel Genellina wrote:
>> En Mon, 09 Mar 2009 15:30:31 -0200, Petr Muller <afri at afri.cz> escribió:
>>
>>> I don't know what else is illegal in xml, so I've searched if there's
>>> some method how to prepare strings for insertion to a xml doc before I
>>> start research on a xml spec and write such function on my own.
>>
>> You don't have to; Python already comes with xml support. Using
>> ElementTree to build the document is usually easier and faster:
>> http://effbot.org/zone/element-index.htm
>
> While I usually second that, this isn't the problem here. This thread is
> about unallowed characters in XML. The set of allowed characters is  
> defined
> here:
>
> http://www.w3.org/TR/xml/#charsets

Ouch. Sorry, I was under the false impression that a) control characters  
were allowed, and b) ElementTree would escape them. Both are wrong, and I  
stand corrected.

-- 
Gabriel Genellina




More information about the Python-list mailing list