Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to parse XML from PL/SQL

jeffreehy-JavaNetMar 23 2019 — edited Mar 24 2019

Hi all.

I'm trying to parse an xml response from PL/SQL but not getting the fields back.

This is my xml:

<?xml version='1.0' encoding='UTF-8'?>

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">

<S:Body>

<ns2:ConsultaEEHResponse xmlns:ns2="http://jeta.servicios.ws/">

<return>

<codigoError>6</codigoError>

<mensaje>El Banco se encuentra Inactivo para Recaudo.</mensaje>

<resultado>false</resultado>

</return>

</ns2:ConsultaEEHResponse>

</S:Body></S:Envelope>

This is my snippet PL/SQL code:

open p_recordset for

    with XML as

     (select XMLTYPE(vCampo1) as OBJECT_VALUE from dual)

    select *

      from XML,

           XMLTABLE(xmlnamespaces('http://schemas.xmlsoap.org/soap/envelope/' as "S",

                           default  'http://jeta.servicios.ws/'),  --  as "ns2",

                                --default 'http://schemas.servicestack.net/types'),

                   '//*:return'

                   passing OBJECT_VALUE columns

                   "codigoError" varchar2(5) PATH 'codigoError',

                   "mensaje" varchar2(200) PATH 'mensaje',

                   "Resultado" varchar2(5) PATH 'resultado') ;

end CONSULTA_EEH;

please help me. Thank you very much.

This post has been answered by mNem on Mar 24 2019
Jump to Answer
Comments
Post Details
Added on Mar 23 2019
2 comments
2,807 views