Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Problem in Casting the encoded string to XML

$
0
0

Hi all,
From dotnet code i have encoded the XML as string and passed this value as XML attribute value in below.

Am not sure if we can have XML as attribute value inside another XML.hence i did with below approach.

Now i have special character '<' in that please refer yellow highlighted.this was having problem in casting to XML.
Kindly assist me.
Thanks in advance. 

DECLARE @XMLXML                       

SET @XML='<Utility><Actions><Action Category="ExecuteSp" SettingName="GetDMS" ComponentId="19">

<Parameters Param="SourceXML" Value="&amp;lt;NewDataSet&amp;gt;&amp;lt;Table1&amp;gt;&amp;lt;DocumentName&amp;gt;US OB&amp;amp;lt; 14 Weeks /Transvaginal&amp;lt;/DocumentName&amp;gt;&amp;lt;/Table1&amp;gt;&amp;lt;/NewDataSet&amp;gt;" /></Action></Actions></Utility>'            

                      

Declare @SourceDMSXMLasvarchar(max)                          

SELECT @SourceDMSXML = @XML.value('(/Utility/Actions/Action/Parameters[@Param = "SourceXML"]/@Value)[1]','varchar(max)')               

           

SET @SourceDMSXML=Replace(@SourceDMSXML,'&amp;lt;','<');                   

SET @SourceDMSXML=Replace(@SourceDMSXML,'&amp;gt;','>');      

SET @SourceDMSXML=Replace(@SourceDMSXML,'&lt;','<');                   

SET @SourceDMSXML=Replace(@SourceDMSXML,'&gt;','>'); 

                        

DECLARE @SourceXMLXML                          

SET @SourceXML=CAST(@SourceDMSXMLASXML)    

select  @SourceXML  


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>