Reputation: 27011
I have a stored procedure which returns 2 xml resultsets as below:
SELECT 1 as SiteID
FOR XML PATH('FirstResultSet'), TYPE
SELECT 1 as UserID
FOR XML PATH('SecondResultSet'), TYPE
I have run my stored procedure and got the DataSet object.
I called the GetXml method and got the xml:
string xml = dataSet.GetXml();
But the xml is as below which is not in the expected format:
<NewDataSet>
<Table><Column1><FirstResultSet><SiteID>1<SiteID><FirstResultSet></Column1></Table>
<Table1><Column1><SecondResultSet><UserID>1<UserID><SecondResultSet></Column1></Table1>
</NewDataSet>
As you see the retrieved text is treated as text rather than xml.
How to get the xml out of this? I know I can just replace "<" and ">" but is there any built-in method for this to make this easier and quicker with better performance?
string xml = dataSet.GetXml().Replace("<", "<").Replace(">", ">");
Thanks,
Upvotes: 0
Views: 1232
Reputation: 460158
Try:
string xml = Server.HtmlDecode(dataSet.GetXml());
http://msdn.microsoft.com/en-us/library/7c5fyk1k.aspx
Maybe you need the exact opposite:
string xml = Server.HtmlEncode(dataSet.GetXml());
http://msdn.microsoft.com/en-us/library/w3te6wfz.aspx
Upvotes: 1