Monday, 14 June 2010

SQL Server XML datatype with CDATA

So today I learnt something new - it turns out the XML datatype in SQL Server does not preserve CDATA sections.
e.g.
DECLARE @XML XML
SET @XML = '<Test><NodeA><![CDATA[Testing cdata section <woop!>]]></NodeA></Test>'
SELECT @XML

Results
------------------------------------------------------------------
<Test><NodeA>Testing cdata section &lt;woop!&gt;</NodeA></Test>
After a quick dig around, I found this MS Connect case. I personally would like to see it accept whatever you pass in without silently altering it, as long as it's well-formed XML of course.

No comments:

Post a Comment