String Data Types
The XML generated by the white space characters in the data is entitized.
The XML generated by the
white space characters in the data is entitized.
The following example creates a sample table
and inserts sample data that includes the line
feed, carriage return, and tab characters. The
statement retrieves the data from the
table.
Here’s the result set.
XML
Note the following from the previous query:
The carriage return in the first row is entitized as.
FOR XML
T
SELECT

CREATE
TABLE
T (
c1
INT identity
PRIMARY
KEY
,
c2
VARCHAR (100)
);
GO
INSERT
T (c2)
VALUES (
'Special character 0xD for carriage return '
+
CONVERT (
VARCHAR (10), 0xD) +
'
after carriage return'
);
INSERT
T (c2)
VALUES (
'Special character 0x9 for tab '
+
CONVERT (
VARCHAR (10), 0x9) +
' after tab'
);
INSERT
T (c2)
VALUES (
'Special character 0xA for line feed '
+
CONVERT (
VARCHAR (10), 0xA) +
' after line feed'
);
GO
SELECT
*
FROM
T
FOR
XML
AUTO
;
GO
<T c1
=
"1"
c2
=
"Special character 0xD for carriage return after carriage return"
/>
<T c1
=
"2"
c2
=
"Special character 0x9 for tab after tab"
/>
<T c1
=
"3"
c2
=
"Special character 0xA for line feed after line feed"
/>