I am running the below query to extract data from an xml column…question is how to extract data that is in between ![CDATA[“”]] ?
select
CAST(xml as xml).value('(//@nodeName)[1]','nvarchar(20)') as NodeName,
CAST(xml as xml).value('(//![CDATA [prdDetDesc]])[1]','nvarchar(225)') as DetDesc,
CAST(xml as xml).value('(//prdImg)[1]','nvarchar(1000)') as prdImage
from [dbo].[cmsContentXml])
I need to extract data that is present between [[“”]]
Thanks in advance
There is nothing special with CDATA sections.
It also handles mixed values.
Result:
Edit
From a table instead of a variable with a cast to XML:
Try it here: https://data.stackexchange.com/stackoverflow/q/108293/
Edit 2
You need to specify the node names in the query. You also have to decide if you should have the different nodes in the same column or if they should be in different columns. Below I show you how you can do both.