I have the following problem, I need to remove the "cfdi_" for "cfdi:"
I used the namespaces to solve that but they are duplicated by each node and I can not eliminate them, If you could help me I would appreciate it
declare @Mydoc xml;
set @Mydoc = (SELECT
'' as importe,
(SELECT Importe, TasaCuota, TipoFactor, Impuesto, Base
FROM CDFIDet
FOR XML RAW('cfdi_traslado'), TYPE, ROOT('cfdi_traslados'))
FROM
CFDIENC
FOR XML RAW('cfdi_gatito'),type)
SELECT @Mydoc;
Result1:
<cfdi:gatito importe="">
<cfdi:traslados>
<cfdi:traslado Importe="1920" TasaCuota="0" TipoFactor="Tasa" Impuesto="16" Base="240" />
<cfdi:traslado Importe="2202" TasaCuota="0" TipoFactor="TASA" Impuesto="16" Base="450" />
</cfdi:traslados>
</cfdi:gatito>
Second attempt:
declare @Mydoc xml;
WITH xmlnamespaces ('uri' as cfdi)
SELECT @Mydoc = (SELECT
'' AS importe,
(SELECT Importe, TasaCuota, TipoFactor, Impuesto, Base
FROM CDFIDet
FOR XML RAW('cfdi:traslado'), TYPE, ROOT('cfdi:traslados'))
FROM CFDIENC
FOR XML RAW('cfdi:gatito'), TYPE)
SELECT @Mydoc;
Result:
<cfdi:gatito xmlns:cfdi="uri" importe="">
<cfdi:traslados xmlns:cfdi="uri">
<cfdi:traslado Importe="1920" TasaCuota="0" TipoFactor="Tasa" Impuesto="16" Base="240" />
<cfdi:traslado Importe="2202" TasaCuota="0" TipoFactor="TASA" Impuesto="16" Base="450" />
</cfdi:traslados>
</cfdi:gatito>
My code is bigger and it is repeated too many times and I do not know how to eliminate them