I need to generate the XML from the SQL Server 2008 R2 using ‘For XML explicit’ and CDATA directive. The output should be like following:-
<?xml version="1.0" encoding="utf-8" ?>
<JOB>
<AD>
<ID><![CDATA[ 451 ]]></ID>
<TITLE><![CDATA[ Receptionist ]]></TITLE>
</AD>
<AD>
<ID><![CDATA[ 1025 ]]></ID>
<TITLE><![CDATA[ Secretary ]]></TITLE>
</AD>
</JOB>
While, the schema of table is,
Table Name : AD
Column1 : ID
Column2 : TITLE
But, I am unable to achieve this and stuck somewhere.
Many thanks.
Result:
Edit:
With root node: