[XML-SIG] Silly question

Walter Underwood wunder@infoseek.com
Fri, 03 Mar 2000 17:10:28 -0800


At 03:46 PM 3/3/00 -0800, brk@jenkon.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 &lt;example&gt; 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".

wunder
--
Walter R. Underwood
Senior Staff Engineer
Infoseek Software
GO Network, part of The Walt Disney Company
wunder@infoseek.com
http://software.infoseek.com/cce/ (my product)
http://www.best.com/~wunder/
1-408-543-6946