[XML-SIG] Silly question
Fri, 03 Mar 2000 17:10:28 -0800
At 03:46 PM 3/3/00 -0800, email@example.com wrote:
>I know I must have just overlooked it somewhere, but does anyone know of a
>function that will take plain text and make it safe for XML? That is, given
>a string like 'This is an <example> of unusable text", convert it to 'This
>is an <example> of unusable text'?
We moved the code to C, since we already had some char-by-char
modules there (HTML-quoting, URL-quoting, ...). But before that,
I did have some Python to do it. The code is lost, or rather
marooned in ClearCase, but here is a very rough outline:
check to see if any special characters exist in the string.
if not, return the string unchanged.
use the re package to match [<>&']
in the match routine, replace the character with its entity
I called it "entify".
Walter R. Underwood
Senior Staff Engineer
GO Network, part of The Walt Disney Company
http://software.infoseek.com/cce/ (my product)