I have this XML, that I am trying to decode with XMLTABLE
Note this is simplified, CommercialData actually contains dozens of fields
The fact that InteractiveResponse has a namespace declaration without including it in the tag name is messing things up for me. I assumed that the XPATH expression for getting to PhCompany would simply be:
But that returned nothing.
After much googling, I found that this would work:
Which means for this one field, my XMLTABLE statement looks like this:
The paths are huge and cumbersome. Is there a better way?
Code:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <InteractiveResponse xmlns="http://www.foo.com/bar/foo/bar/"> <OutputRoot> <Output> <CommercialData> <Identifiers> <pHCompany>gbr100001046</pHCompany> </Identifiers> </CommercialData> </Output> </OutputRoot> </InteractiveResponse> </soap:Body> </soap:Envelope>
The fact that InteractiveResponse has a namespace declaration without including it in the tag name is messing things up for me. I assumed that the XPATH expression for getting to PhCompany would simply be:
Code:
/*:Envelope/*:Body/InteractiveResponse/OutputRoot/Output/CommercialData/Identifiers/pHCompany
After much googling, I found that this would work:
Code:
/*:Envelope/*:Body/*[local-name()='InteractiveResponse']/*[local-name()='OutputRoot']/*[local-name()='Output']/*[local-name()='CommercialData']/*[local-name()='Identifiers']/*[local-name()='pHCompany']
Code:
select pHCompany from MYFILE f1, xmltable('/*:Envelope/*:Body/*[local-name()=''InteractiveResponse'']/*[local-name()=''OutputRoot''] /*[local-name()=''Output'']/*[local-name()=''CommercialData'']' passing XMLIN columns pHCompany varchar(15) path '*[local-name()=''Identifiers''] /*[local-name()=''pHCompany'']') as commercial
Comment