Consulta SQL a XML
Publicado por Gerald (3 intervenciones) el 04/07/2018 16:51:52
Hola,
Tengo una consulta con varios root y path.
El problema es que ocupo utilizar en el primer root la variable xmlns. Pero me refleja incorrecta en el codigo (@xmlns).
Intente ingresar ;WITH XMLNAMESPACES (DEFAULT 'http://www.ejemplo.com')
Pero me lo ingreso en no solo en 'Feed' sino que tambien en Productos/Attributos.
Como puedo usar la variable xmlns?
Saludos
Tengo una consulta con varios root y path.
El problema es que ocupo utilizar en el primer root la variable xmlns. Pero me refleja incorrecta en el codigo (@xmlns).
Intente ingresar ;WITH XMLNAMESPACES (DEFAULT 'http://www.ejemplo.com')
Pero me lo ingreso en no solo en 'Feed' sino que tambien en Productos/Attributos.
Como puedo usar la variable xmlns?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
select 'Person' as "@xmlns", 'Hola' as "@url",
(select
ClienteIdentificacion as 'Campo1',
ClienteNombreCompleto as 'Campo2',
(
SELECT
ClienteNombre AS 'ValorRepetido',
'',
ClienteApellido1 AS 'ValorRepetido',
'',
ClienteApellido2 AS 'ValorRepetido'
for xml path('Valores'),type
),
(
SELECT
'ClienteProvincia' as 'Attribute/@id',
ClienteProvincia as 'Valor',
'',
'ClienteCanton' as 'Attribute/@id',
ClienteCanton as 'Valor'
for xml path('Attributes'),type
)
from TD_CLIENTE
for xml path('Product'), root('Products'), type)
for xml path('Feed')
Saludos
Valora esta pregunta


0