Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
SQL
ce
clients
clustering
connect
datamining
datawarehouse
dts
fulltext
jdbcdriver
msde
mseq
newusers
notificationsvcs
odbc
olap
programming
replication
reportingsvcs
security
securitytools
server
setup
sqlxml.viewmapper
tools
xml
  
 
date: Mon, 9 Jun 2008 05:55:41 -0700,    group: microsoft.public.sqlserver.xml        back       


Create XML, first line   
How do I add <?xml version="1.0" encoding="UTF-8"?> to the first line of the 
output from this query?

select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as 
[variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')

Thanks!
date: Mon, 9 Jun 2008 05:55:41 -0700   author:   Anders

Re: Create XML, first line   
Anders wrote:
> How do I add <?xml version="1.0" encoding="UTF-8"?> to the first line of the 
> output from this query?
> 
> select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as 
> [variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')

I don't think the FOR XML clause allows you to output an XML declaration.


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Mon, 09 Jun 2008 15:01:54 +0200   author:   Martin Honnen

Re: Create XML, first line   
How can I generate a valid xml output in this case then?

"Martin Honnen" wrote:

> Anders wrote:
> > How do I add <?xml version="1.0" encoding="UTF-8"?> to the first line of the 
> > output from this query?
> > 
> > select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as 
> > [variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')
> 
> I don't think the FOR XML clause allows you to output an XML declaration.
> 
> 
> -- 
> 
> 	Martin Honnen --- MVP XML
> 	http://JavaScript.FAQTs.com/
>
date: Mon, 9 Jun 2008 06:37:00 -0700   author:   Anders

Re: Create XML, first line   
Anders wrote:
> How can I generate a valid xml output in this case then?

The XML declaration is optional for encodings UTF-8 and UTF-16.
Why do you think you need it?


-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Mon, 09 Jun 2008 15:57:44 +0200   author:   Martin Honnen

Re: Create XML, first line   
The application reading the xml requires this.
date: Mon, 9 Jun 2008 07:27:01 -0700   author:   Anders

Re: Create XML, first line   
Try putting the FOR XML EXPLICIT in a subquery (***untested***):

DECLARE @v VARCHAR(MAX);

SET @v = '<?xml version="1.0" encoding="UTF-8"?>' +
(
  select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as
  [variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')
);

Obviously won't work if you're using SQL 2000.

========
Michael Coles
"Pro SQL Server 2008 XML"
http://www.amazon.com/Pro-SQL-Server-2008-XML/dp/1590599837/


"Anders"  wrote in message 
news:F687A896-0D9E-49C8-B04F-516055D762D5@microsoft.com...
> How do I add <?xml version="1.0" encoding="UTF-8"?> to the first line of 
> the
> output from this query?
>
> select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as
> [variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')
>
> Thanks!
>
date: Sat, 14 Jun 2008 17:28:31 -0400   author:   Michael Coles michaelcoREPLACE_THIS_WITH_AT_SIGNoptonline.net

Re: Create XML, first line   
Try something like this (***untested***):

DECLARE @v varchar(max);

SET @v = '<?xml version="1.0" encoding="UTF-8"?>' +
(
  select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as
  [variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')
);

Obviously won't work on SQL 2000.

-- 

========
Michael Coles
"Pro SQL Server 2008 XML"
http://www.amazon.com/Pro-SQL-Server-2008-XML/dp/1590599837/


"Anders"  wrote in message 
news:F687A896-0D9E-49C8-B04F-516055D762D5@microsoft.com...
> How do I add <?xml version="1.0" encoding="UTF-8"?> to the first line of 
> the
> output from this query?
>
> select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as
> [variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')
>
> Thanks!
>
date: Sat, 14 Jun 2008 17:32:38 -0400   author:   Michael Coles michaelcoREPLACE_THIS_WITH_AT_SIGNoptonline.net

RE: Create XML, first line   
See my reply to "SQL to XML question" 7 posts up on 22/06/2008.

http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?&lang=en&cr=us&guid=&sloc=en-us&dg=microsoft.public.sqlserver.xml&p=1&tid=960534cb-432e-40f5-9ccc-b8150dd594c1

HTH
wBob
"Anders" wrote:

> How do I add <?xml version="1.0" encoding="UTF-8"?> to the first line of the 
> output from this query?
> 
> select 1 as TAG, NULL as Parent, xx as [variable!1!name], yy as 
> [variable!1!!element] FROM zz for XML EXPLICIT, ROOT('test')
> 
> Thanks!
>
date: Fri, 27 Jun 2008 02:56:02 -0700   author:   Bob

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us