I have a sample input looking like below in one of the columns in the table.
<OrderNotification xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<POSKI xmlns="http://MyCompany.co.nz">12345</POSKI>
<BUKRS xmlns="http://MyCompany.co.nz">ABCD</BUKRS>
<PRCTR xmlns="http://MyCompany.co.nz">1324</PRCTR>
</OrderNotification>
I need to shred this XML to extract the values from the message. However, because of the namespace in the child nodes, i'm unable to do so. Following a suggestion from my previous question, I wrote my query as below.
DECLARE @OrderLogs TABLE ( OrderNotification XML);
INSERT INTO @ProjectLogs (OrderNotification)
(SELECT Info
FROM [MainLogging].[dbo].[JobLogs]
WHERE EventId = 'XXXXXXXX'
AND Message ='OrderNotification');
WITH XMLNAMESPACES (DEFAULT 'http://mycompany.co.nz')
SELECT
c.value('(POSKI/text())[1]','VARCHAR(20)') AS ORDER,
c.value('(BUKRS/text())[1]','VARCHAR(256)') AS DESCRIPTION
FROM
@ProjectLogs
CROSS APPLY
OrderNotification.nodes('/OrderNotification') AS t(c);
It's not returning any output because I'm not referencing the nodes correctly. Can anyone help please?
Thanks in advance