Robert Dailey wrote:
> Both strings in your example are exactly the same, unless I'm missing
> something.
> 
> On 8/2/07, Roman <[EMAIL PROTECTED]> wrote:
>> Is there a package that converts a string that contains special
>> characters in xml to to literal value.  For instance, converts string
>> http://myhome/&param to http://myhome/&amp;param.
>>
>> Thanks in advance
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list


Robert, your newsreader/mail program is converting the HTML/XML entity codes 
into the corresponding character so you're not seeing the plain text version of 
what the OP posted. He's asking for code to convert XML entities like '&' into 
their escaped strings. 

I believe xml.sax.saxutils.encode() is what the OP is looking for:

>>> import xml.sax.saxutils
>>> xml.sax.saxutils.escape('http://myhome/&param')
'http://myhome/&amp;param'

-Jay
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to