2

I have a customer using a platform we have developed that allows customer webservice return data to be parsed by a stored procedure in MSSQL. We have a customer sending xml back that contains nested xmlns="xxxxxx" declarations that are to different URI locations. First off is this valid? And secondly is it possible to parse using XQuery? I have tried using both .value and .query capabilities of the t-sql xml datatype to try to work through the issue but the point where the "second default namespace" comes into play seems to be a boundary that is nearly impossible to cross using techniques I am aware of. Here is a sample xml response:

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
     <soapenv:Body>
      <FF_LOG_RSPD_CONT xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/X.V1">
       <FF_LOGIN_WSDL_RSPD>
        <FF_PYIVR_RS_DER xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/Y.V1">
         <EMPLID>111111</EMPLID>
         <PIN>2222</PIN>
         <NEW_PIN_FLAG>N</NEW_PIN_FLAG>
         <REVOKE_FLAG>N</REVOKE_FLAG>
         <LAST_4_OF_SSN></LAST_4_OF_SSN>
         <WSDL_SUCCESS_FLAG>Y</WSDL_SUCCESS_FLAG>
        </FF_PYIVR_RS_DER>
       </FF_LOGIN_WSDL_RSPD>
      </FF_LOG_RSPD_CONT>
     </soapenv:Body>
    </soapenv:Envelope>

1 Answer 1

3

Can you try explicitly calling out the namespaces?

declare @theXml XML = '<?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
     <soapenv:Body>
      <FF_LOG_RSPD_CONT xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/X.V1">
       <FF_LOGIN_WSDL_RSPD>
        <FF_PYIVR_RS_DER xmlns="http://xmlns.oracle.com/Enterprise/Tools/schemas/Y.V1">
         <EMPLID>111111</EMPLID>
         <PIN>2222</PIN>
         <NEW_PIN_FLAG>N</NEW_PIN_FLAG>
         <REVOKE_FLAG>N</REVOKE_FLAG>
         <LAST_4_OF_SSN></LAST_4_OF_SSN>
         <WSDL_SUCCESS_FLAG>Y</WSDL_SUCCESS_FLAG>
        </FF_PYIVR_RS_DER>
       </FF_LOGIN_WSDL_RSPD>
      </FF_LOG_RSPD_CONT>
     </soapenv:Body>
    </soapenv:Envelope>'

SELECT
    @theXml.value('
        declare namespace ns1="http://schemas.xmlsoap.org/soap/envelope/";
        declare namespace ns2="http://xmlns.oracle.com/Enterprise/Tools/schemas/X.V1";
        declare namespace ns3="http://xmlns.oracle.com/Enterprise/Tools/schemas/Y.V1";
        (/ns1:Envelope/ns1:Body/ns2:FF_LOG_RSPD_CONT/ns2:FF_LOGIN_WSDL_RSPD/ns3:FF_PYIVR_RS_DER/ns3:EMPLID)[1]', 
        'nvarchar(max)') as result

Results:

111111
Sign up to request clarification or add additional context in comments.

1 Comment

Well that couldn't have been simpler! Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.