Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 using XMLPATH

Author  Topic 

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2011-12-03 : 00:20:24
Hi All,

I want to generate the xml using xmlpath as below:

<s t='3' a='3'>
<c k='RelayServer'>apsqa01</c>
</s>
I have written like this
select
'3' AS 's/@t',
'3' AS 's/@a',
'RelayServer' AS 's/c/@k',
'apsqa01' AS 'c'
FOR XML PATH('')

but iam getting output like below :
<s>
<s t="3" a="3">
<c k="RelayServer" />
</s>
<c>apsqa01</c>
</s>
kindly help me on the same

rams

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-03 : 00:27:59
it should be as below

select
'3' AS 's/@t',
'3' AS 's/@a',
'RelayServer' AS 's/c/@k',
'apsqa01' AS 's/c'
FOR XML PATH('')


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2011-12-03 : 00:32:36
thanks visakh, it worked :)

rams
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-03 : 01:42:28
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -