XML Processing

Cameron Laird claird at lairds.us
Fri Aug 3 09:35:14 EDT 2007


In article <1186082619.193097.207650 at x40g2000prg.googlegroups.com>,
 <kyosohma at gmail.com> wrote:
>On Aug 2, 2:09 pm, Jay Loden <pyt... at jayloden.com> wrote:
>> kyoso... at gmail.com wrote:
>> > On Aug 2, 1:45 pm, Roman <rgelfa... at hotmail.com> wrote:
>> >> Is there a package that converts a string that contains special
>> >> characters in xml to to literal value.  For instance, converts
>stringhttp://myhome/&paramtohttp://myhome/&param.
>>
>> >> Thanks in advance
>>
>> > I've seen examples using the HTMLgen module. But here's another script
>> > I just found:
>>
>> >http://mail.python.org/pipermail/python-list/1999-November/016814.html
>>
>> > I would think that you could use regular expressions too.
>>
>> > Mike
>>
>> I would reccommend against using the example above or using regular
>expressions, since both are likely to miss corner cases, and the stdlib
>has an encode function that's already designed for this task
>>
>> http://docs.python.org/lib/module-xml.sax.saxutils.html
>>
>> The encode() function in xml.sax.saxutils also is extensible, should
>you run into any entities that it fails to escape in the current
>implementation.
>>
>> -Jay
>
>Yes, I am an idiot.
>

!  Unproved, as Scotsmen are wont to say.

This and similar questions arise frequently enough that I recommend
<URL: http://wiki.python.org/moin/EscapingXml > for those who want
to pursue the subject.



More information about the Python-list mailing list