I just want an actualEndTime - is that so much to ask?
declare @x xml = '
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<bogus>1934</bogus>
<getJobActionsResponse xmlns="urn:JobService">
<getJobActionsReturn>
<job xmlns:ns1="urn:JobService" xsi:type="ns1:SvcJob">
<actions />
<actualEndTime>
<dateString>2019-05-15 19:46:54.207</dateString>
</actualEndTime>
</job>
</getJobActionsReturn>
</getJobActionsResponse>
</soapenv:Body>
</soapenv:Envelope>'
It seems from posts like this that I should be able to do a query like this:
;with xmlnamespaces (N'http://schemas.xmlsoap.org/soap/envelope/' as ns0,
N'urn:JobService' as ns2)
select @x.value('(/ns0:envelope/ns0:body/ns2:getJobActions/ns2:getJobActionsReturn/ns2:job/ns2:actualEndTime)[1]', 'nvarchar(max)')
I've tried various permutations of namespace prefixing, but everything I try returns null. I can't even get an upstream bogus value to return non-null:
;with xmlnamespaces (N'http://schemas.xmlsoap.org/soap/envelope/' as ns0)
select @x.value('(/ns0:envelope/ns0:body/ns0:bogus)[1]', 'nvarchar(max)')
I don't get namespaces (every web page explaining them seems to be a mile long). Sorry, please and thanks.
SELECT @x.value('(//*:actualEndTime/*:dateString/text())[1]','datetime')