|
Home > Archive > MS SQL XML > October 2006 > Problem with CDATA section in XQuery
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Problem with CDATA section in XQuery
|
|
| mindflower 2006-10-28, 7:30 pm |
| Hi,
i am trying to insert a CDATA section using XQuery in T-SQL. I am following
the example from books online
http://msdn2.microsoft.com/en-us/library/ms175466.aspx and i keep getting the
error 'XQuery [modify()]: Syntax error near '<!''
The code is:
DECLARE @myDoc xml
SET @myDoc =
'<Root>
<ProductDescription ProductID="1" ProductName="Road Bike">
<Features> </Features>
</ProductDescription>
</Root>'
SELECT @myDoc
SET @myDoc.modify('
insert <![CDATA[ <notxml> as text </notxml> or cdata ]]>
into (/Root/ProductDescription/Features)[1] ')
SELECT @myDoc ;
Does anyone have a solution for this?
Thanks,
Stefan
| |
| markc600@hotmail.com 2006-10-31, 12:25 am |
|
I think you can achieve the same effect by doing this
SET @myDoc.modify('
insert text {"<notxml> as text </notxml> or cdata"}
into (/Root/ProductDescription/Features)[1]')
| |
| Kent Tegels 2006-10-31, 12:25 am |
| Hello markc600@hotmail.com,
Not really. If he really does want to use the CDATA tag here, he can't --
the content doesn't mater. I suspect, but XMLRW isn't parsing it correctly.
This smells like a bug to me.
Thanks,
Kent Tegels
http://staff.develop.com/ktegels/
| |
| Denis Ruckebusch [MSFT] 2006-10-31, 12:25 am |
| In this case I believe you should be able to use the text node constructor, like
this
SET @myDoc.modify('insert text{"<notxml> as text </notxml> or cdata"} into
(/Root/ProductDescription/Features)[1] ')
Denis Ruckebusch
SQL Server XML datatype test team
http://blogs.msdn.com/denisruc
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"mindflower" < mindflower@discussio
ns.microsoft.com> wrote in message
news:9DBECB6E-006B-4537-A039- CEEA784B9FD8@microso
ft.com...
> Hi,
>
> i am trying to insert a CDATA section using XQuery in T-SQL. I am following
> the example from books online
> http://msdn2.microsoft.com/en-us/library/ms175466.aspx and i keep getting the
> error 'XQuery [modify()]: Syntax error near '<!''
>
> The code is:
>
> DECLARE @myDoc xml
> SET @myDoc =
> '<Root>
> <ProductDescription ProductID="1" ProductName="Road Bike">
> <Features> </Features>
> </ProductDescription>
> </Root>'
> SELECT @myDoc
> SET @myDoc.modify('
> insert <![CDATA[ <notxml> as text </notxml> or cdata ]]>
> into (/Root/ProductDescription/Features)[1] ')
> SELECT @myDoc ;
>
> Does anyone have a solution for this?
>
> Thanks,
> Stefan
|
|
|
|
|