RAW Mode

for RuBoard

RAW mode is the simplest of the three basic FOR XML modes. It performs a very basic translation of the result set into XML. Here's an example:

 SELECT CustomerId, CompanyName FROM Customers FOR XML RAW 

(Results abridged)

 XML_F52E2B61-18A1-11d1-B105-00805F49916B --------------------------------------------------------------------------- <row CustomerId="ALFKI" CompanyName="Alfreds Futterkiste"/><row CustomerId="ANATR" CompanyName="Ana Trujillo Emparedados y helados"/><row CustomerId="ANTON" CompanyName="Antonio Moreno Taquer?a"/><row CustomerId="AROUT" CompanyName="Around the Horn"/><row CustomerId="BERGS" CompanyName="Berglunds snabbk?p"/><row CustomerId="BLAUS" CompanyName="Blauer See Delikatessen"/><row CustomerId="BLONP" CompanyName="Blondesddsl pre et fils"/><row CustomerId="WELLI" CompanyName="Wellington Importadora"/><row CustomerId="WHITC" CompanyName="White Clover Markets"/><row CustomerId="WILMK" CompanyName="Wilman Kala"/><row CustomerId="WOLZA" CompanyName="Wolski Zajazd"/> 

Each column becomes an attribute in the result set, and each row becomes an element with the generic name of row.

As I've mentioned before, keep in mind that the XML that's returned by FOR XML is not well formed because it lacks a root element. It's technically an XML fragment, and you must supply a root element in order for the document to be usable by an XML parser.

for RuBoard


The Guru[ap]s Guide to SQL Server[tm] Stored Procedures, XML, and HTML
The Guru[ap]s Guide to SQL Server[tm] Stored Procedures, XML, and HTML
ISBN: 201700468
EAN: N/A
Year: 2005
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net