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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help with WITH XMLNAMESPACES

Author  Topic 

Mathias
Posting Yak Master

119 Posts

Posted - 2008-10-10 : 04:25:03
I need to create the following XML:

<?xml version="1.0" encoding="UTF-8" ?>
<S16 creationDateTime="2008-04-01T09:30:47.0Z" version="1.0" xsi:schemaLocation="http://www.bcl.lu/2008/S1.6 ../S16.xsd" xmlns="http://www.bcl.lu/2008/S1.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

my best rest is done by using :

WITH XMLNAMESPACES ('http://www.bcl.lu/2008/S1.3../S16.xsd' as schemaLocation,'http://www.w3.org/2001/XMLSchema-intance' as xsi
,DEFAULT 'http://www.bcl.lu/2008/S1.6')
select getdate() as '@creationDateTime'
, '1.0' as '@version'
for XML PATH('S16')

I dont manage to get the xsi:schemaLocation right and I don't know how to add the first line. Thanks

Mathias
Posting Yak Master

119 Posts

Posted - 2008-10-10 : 05:34:37
I have managed to improve the results with:

WITH XMLNAMESPACES (DEFAULT 'http://www.bcl.lu/2008/S1.6')
select
'http://www.bcl.lu/2008/S1.6 ../S16.xsd' as '@xsi:schemaLocation'
, getdate() as '@creationDateTime'
, '1.0' as '@version'
for XML PATH('S16'), ELEMENTS XSINIL
Go to Top of Page
   

- Advertisement -