Last post Aug 12, 2009 02:53 AM by jacob_sebastian
Aug 06, 2009 03:22 AM|faisalv|LINK
I just have a issue with generating XML from SQL Server. See sample below.
SET @xmlsample='<?xml version="1.0" encoding="iso-8859-1"
SET @xmlsample= @xmlsample
The output of the query is as follows.
However I want the output to include the encoding tag as below.
Do you know of a way which I can do this?
Aug 06, 2009 04:58 AM|rashmika|LINK
Aug 06, 2009 05:11 AM|faisalv|LINK
These articles does not show you how to generate xml with version and encoding tag.
<?xml version="1.0" encoding="iso-8859-1" ?>
That is what I need my generated XML to have.
Aug 06, 2009 06:38 AM|rashmika|LINK
Aug 11, 2009 06:00 AM|Jian Kang - MSFT|LINK
Please see the following description:
SQL Server internally represents XML in an efficient binary representation that uses UTF-16 encoding. User-provided encoding is not preserved, but is considered during the parse process.
Generating XML Instances
That’s why there is no XML encoding returned in your case. Please refer to the following link, which suggests convert the XML to a string type and then add the XML declaration.
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore,
Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you
completely understand the risk before retrieving any software from the Internet.
Aug 12, 2009 02:53 AM|jacob_sebastian|LINK
The XML data type (SQL Server) does not preserve processing information. So if you assign an XML document with processing information, it will be lost. If you want to return an XML document with processing information, you should return a well-formed XML
string, instead of returning an XML data type value.