| Re: XML Data Type - Illegal Characters |
|
 |
|
 |
|
 |
|
 |
Group: microsoft.public.sqlserver.xml · Group Profile
Author: Peter FlynnPeter Flynn Date: Aug 28, 2006 15:12
Amos Soma wrote:
> In my SQL app, I am converting a varchar(max) type, passed to a stored
> procedure, to an XML data type in the stored proc.
>
> I've noticed that if the contents of the varchar(max) string contains
> illegal XML characters (such as '&'), the conversion will fail. This doesn't
> surprise me, and I would expect that. My question is this. Is there any SQL
> function I can call, or some other method, that will convert all illegal XML
> characters to legal equivalents?
There are only two characters which need converting: & must be &
and < must be < (do the first before the second :-)
They're not illegal, just reserved. Real illegal characters are defined
in the XML Spec, and they are mostly control characters which certainly
shouldn't be in any normal text string.
///Peter
|