I have some XML that has creating using an XmlDocument object in C#.
I am then inserting the xml data into an XML column in SQL 2005 using the XmlDocument.OuterXml method to get the raw xml.
The problem I have is that the xml contains some special characters. Namely: 
This is because the xml is built up from user input from various sources.
When I am performing the insert I get a SQL error message saying XML parsing: illegal xml character.
CREATE TABLE #MyTable (MyColumn XML)
INSERT INTO #MyTable VALUES ('<Element></Element>')
Msg 9420, Level 16, State 1, Line 2
XML parsing: line 1, character 15, illegal xml character
Can someone point me in a direction as to how I can solve this?
It will be extremely hard for me to change anything on the XmlDocument object or original xml itself, however, I can change the mechanism I use to get at the RAW XML. I can also change my database settings if required.