how would you write a t-sql query if the namespace is prefixed in all of the elements? I've tried many variations, and this is what I've got so far, but it just doesn't work...
DECLARE @x xml
SET @x = (SELECT xml_data_column FROM dbo.Table
WHERE xmlFileName = 'E:\trnFile.xml' )
;WITH XMLNAMESPACES('http://schemas.xmlsoap.org/soap/envelope/' AS [soap]
, 'tns:RetrievePurchaseResponse xmlns:tns="urn:Transaction"' AS tns)
SELECT t.c.value('orderRef[1]', 'int') orderReference
, t.c.value('orderNumber[1]', 'varchar(100)') orderNumber
, t.c.value('subtotal[1]', 'varchar(100)') subtotal
FROM @x.nodes('/soap:Envelope/soap:Body/tns:RetrievePurchaseResponse/tns:purchase') AS t(c)
Assistance will be greatly appreciated !
Here is the XML input file:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<tns:RetrievePurchaseResponse xmlns:tns="urn:Transaction">
<tns:purchase>
<tns:orderRef>10027</tns:orderRef>
<tns:orderNumber>425816</tns:orderNumber>
<tns:subtotal>95.00</tns:subtotal>
</tns:purchase>
</tns:RetrievePurchaseResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Expected output would be
orderReference, orderNumber, orderUserEmail
10027, 425816, user@domain.com