Hello,
I'm trying to query fields from the following XML query, (which is really a web service call):
<soap:Envelope xmlns:xsi="[schema]" xmlns:xsd="[shema]" xmlns:soap="[schema]">
<soap:Body>
<RunPackage xmlns="http://tempuri.org/">
<xmlDoc>
<Request>
<SubscriberCode>543253</SubscriberCode>
<CompanyCode>54325</CompanyCode>
<BranchName>TestBranchName</BranchName>
<TempWorksUserName>TempWorksUserName</TempWorksUserName>
[...]
With the following XML Query:
WITH XMLNAMESPACES('[schema]' AS soap2, DEFAULT '[schema]')
SELECT TransactionID, T2.Loc.query('data(Request/SubscriberCode)') as 'SubscriberCode'
FROM TempWorksRequest
CROSS APPLY RequestXML.nodes('soap2:Envelope/soap2:Body/RunPackage/xmlDoc') as T2(Loc)
It runs but does not return any retults!
If I build the same query but remove the namespace stuff THEN it works. For example, the following works fine:
<xmlDoc> <Request> <SubscriberCode>543253</SubscriberCode> <CompanyCode>54325</CompanyCode> <BranchName>TestBranchName</BranchName> [...]
SQL Query:
-- Define a namespace for MITS so we can use the MITS namespace. WITH XMLNAMESPACES('[schema]' AS soap2, DEFAULT '[schema]')
SELECT TransactionID, T2.Loc.query('data(Request/SubscriberCode)') as 'SubscriberCode' FROM TempWorksRequest CROSS APPLY RequestXML.nodes('xmlDoc') as T2(Loc)
Any ideas?