Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 21st, 2007, 09:05 AM
Registered User
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Server 2005 XML: FOR XML PATH -> cdata?


Is it possible to output a column as cdata when using xml path?
For example:
SELECT CustomerID as "@CustomerID", 
           Address as "address/street",
           City as "address/city",
           Region as "address/region",
           PostalCode as "address/zip",
           Country as "address/country",
           ContactName as "contact/name",
           ContactTitle as "contact/title",
           Phone as "contact/phone", 
           Fax as "contact/fax"
FROM Customers
FOR XML PATH('Customer'), ROOT('doc')
Is there a way to output street address as cdata? Right now I'm using FOR XML EXPLICIT to output cdata, but my query is getting quite complicated and I would like to switch to the path method.


Old July 8th, 2008, 02:40 AM
Registered User
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

You should use FOR XML EXPLICIT if you intend to generate CDATA sections.

Jacob Sebastian SQL Server MVP www.sqlserverandxml.com www.sqlkatmai.com

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML vs SQL Server 2005 yadavrahul2k5 XML 2 June 1st, 2008 02:59 AM
Transform SQL server 2005 XML with xslt bonekrusher XSLT 0 July 11th, 2007 07:45 PM
Looping through XML in SQL Server 2005 francislang SQL Server 2005 1 February 23rd, 2006 11:47 AM
Achitecture ? SQL -> XML -> ASP -> PDF or HTML Frm jstrong Classic ASP XML 0 July 9th, 2005 01:18 PM
XML to (different <tag>) XML mapping Thodoris XML 4 April 27th, 2004 04:02 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.